diff options
author | vasraz <vasyl.razinkov@est.tech> | 2021-03-22 15:33:06 +0000 |
---|---|---|
committer | Christophe Closset <christophe.closset@intl.att.com> | 2021-03-24 06:59:47 +0000 |
commit | d378c37fbd1ecec7b43394926f1ca32a695e07de (patch) | |
tree | 5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/api/openecomp-sdc-rest-webapp | |
parent | a6ae7294ecd336d7e88f915710b08e2658eaee00 (diff) |
Reformat openecomp-be
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Issue-ID: SDC-3449
Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp')
295 files changed, 8304 insertions, 9959 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/Actions.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/Actions.java index dfcbee67a1..884077b30f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/Actions.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/Actions.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,28 +17,34 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.action.rest; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.openecomp.sdcrests.action.types.ActionResponseDto; import org.openecomp.sdcrests.action.types.ListResponseWrapper; import org.springframework.validation.annotation.Validated; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - /** * Defines various CRUD API that can be performed on Action. */ @@ -49,152 +55,136 @@ import javax.ws.rs.core.Response; @Validated public interface Actions { - /** - * List All Major, Last Minor and Candidate version if any for Given Action Invariant UuId - * - * @return List of All Major, Last Minor and Candidate version if any Of Action with given - actionInvariantUuId. If actionUuId is provided then only action with given actionInvariantUuId - and actionUuId - */ - @GET - @Path("/{actionInvariantUuId}") - @Operation(description = "List Actions For Given Action Invariant UuId", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ListResponseWrapper.class)))) - Response getActionsByActionInvariantUuId( - @PathParam("actionInvariantUuId") String actionInvariantUuId, - @QueryParam("version") String actionUuId, @Context HttpServletRequest servletRequest); - - /** - * Get list of actions based on a filter criteria. If no filter is sent all actions will be - * returned - * - * @return List Of Last Major and Last Minor of All Actions based on filter criteria - */ - @GET - @Operation(description = "List Filtered Actions ", - summary = "Get list of actions based on a filter criteria | If no filter is sent all actions " - + "will be returned", - responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ListResponseWrapper.class)))) - Response getFilteredActions(@QueryParam("vendor") String vendor, - @QueryParam("category") String category, - @QueryParam("name") String name, - @QueryParam("modelId") String modelId, - @QueryParam("componentId") String componentId, - @Context HttpServletRequest servletRequest); - - /** - * List OPENECOMP Components supported by Action Library. - * - * @return List of OPENECOMP Components supported by Action Library - */ - @GET - @Path("/components") - @Operation(description = "List OPENECOMP Components supported by Action Library", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ListResponseWrapper.class)))) - Response getOpenEcompComponents(@Context HttpServletRequest servletRequest); - - /** - * Create a new Action based on request JSON. - * - * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action - */ - @POST - @Operation(description = "Create a new Action") - Response createAction(String requestJson, @Context HttpServletRequest servletRequest); - - /** - * Update an existing action with parameters provided in requestJson. - * - * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action - */ - @PUT - @Path("/{actionInvariantUuId}") - @Operation(description = "Update an existing action") - Response updateAction(@PathParam("actionInvariantUuId") String actionInvariantUuId, - String requestJson, @Context HttpServletRequest servletRequest); - - /** - * Delete an action. - * - * @param actionInvariantUuId Invariant UuId of the action to be deleted - * @param servletRequest Servlet request object - * @return Empty response object - */ - @DELETE - @Path("/{actionInvariantUuId}") - @Operation(description = "Delete Action") - Response deleteAction(@PathParam("actionInvariantUuId") String actionInvariantUuId, - @Context HttpServletRequest servletRequest); - - /** - * Performs Checkout/Undo_Checkout/Checkin/Submit Operation on Action. - * - * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action - */ - @POST - @Path("/{actionInvariantUuId}") - @Operation(description = "Actions on a action", - summary = "Performs one of the following actions on a action: |" - + "Checkout: Locks it for edits by other users. Only the locking user sees the edited " - + "version.|" - + "Undo_Checkout: Unlocks it and deletes the edits that were done.|" - + "Checkin: Unlocks it and activates the edited version to all users.| " - + "Submit: Finalize its active version.|") - Response actOnAction(@PathParam("actionInvariantUuId") String actionInvariantUuId, - String requestJson, @Context HttpServletRequest servletRequest); - - /** - * Upload an artifact to an action. - * - * @param actionInvariantUuId Invariant UuId of the action to which the artifact is uploaded - * @param artifactName Name of the artifact - * @param artifactLabel Label of the artifact - * @param artifactCategory Category of the artifact - * @param artifactDescription Description of the artifact - * @param artifactProtection Artifact protection mode - * @param checksum Checksum of the artifact - * @param artifactToUpload Artifact content object - * @param servletRequest Servlet request object - * @return Generated UuId of the uploaded artifact - */ - @POST - @Path("/{actionInvariantUuId}/artifacts") - @Consumes(MediaType.MULTIPART_FORM_DATA) - Response uploadArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId, - @Multipart(value = "artifactName", required = false) String artifactName, - @Multipart(value = "artifactLabel", required = false) String artifactLabel, - @Multipart(value = "artifactCategory", required = false) String artifactCategory, - @Multipart(value = "artifactDescription", required = false) String artifactDescription, - @Multipart(value = "artifactProtection", required = false) String artifactProtection, - @HeaderParam("Content-MD5") String checksum, - @Multipart(value = "uploadArtifact", required = false) Attachment artifactToUpload, - @Context HttpServletRequest servletRequest); + /** + * List All Major, Last Minor and Candidate version if any for Given Action Invariant UuId + * + * @return List of All Major, Last Minor and Candidate version if any Of Action with given actionInvariantUuId. If actionUuId is provided then + * only action with given actionInvariantUuId and actionUuId + */ + @GET + @Path("/{actionInvariantUuId}") + @Operation(description = "List Actions For Given Action Invariant UuId", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ListResponseWrapper.class)))) + Response getActionsByActionInvariantUuId(@PathParam("actionInvariantUuId") String actionInvariantUuId, @QueryParam("version") String actionUuId, + @Context HttpServletRequest servletRequest); + + /** + * Get list of actions based on a filter criteria. If no filter is sent all actions will be returned + * + * @return List Of Last Major and Last Minor of All Actions based on filter criteria + */ + @GET + @Operation(description = "List Filtered Actions ", summary = "Get list of actions based on a filter criteria | If no filter is sent all actions " + + "will be returned", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ListResponseWrapper.class)))) + Response getFilteredActions(@QueryParam("vendor") String vendor, @QueryParam("category") String category, @QueryParam("name") String name, + @QueryParam("modelId") String modelId, @QueryParam("componentId") String componentId, + @Context HttpServletRequest servletRequest); + + /** + * List OPENECOMP Components supported by Action Library. + * + * @return List of OPENECOMP Components supported by Action Library + */ + @GET + @Path("/components") + @Operation(description = "List OPENECOMP Components supported by Action Library", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ListResponseWrapper.class)))) + Response getOpenEcompComponents(@Context HttpServletRequest servletRequest); + + /** + * Create a new Action based on request JSON. + * + * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action + */ + @POST + @Operation(description = "Create a new Action") + Response createAction(String requestJson, @Context HttpServletRequest servletRequest); + + /** + * Update an existing action with parameters provided in requestJson. + * + * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action + */ + @PUT + @Path("/{actionInvariantUuId}") + @Operation(description = "Update an existing action") + Response updateAction(@PathParam("actionInvariantUuId") String actionInvariantUuId, String requestJson, + @Context HttpServletRequest servletRequest); - @GET - @Path("/{actionUuId}/artifacts/{artifactUuId}") - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Operation(description = "Downloads artifact for action") - Response downloadArtifact(@PathParam("actionUuId") String actionUuId, - @PathParam("artifactUuId") String artifactUuId, + /** + * Delete an action. + * + * @param actionInvariantUuId Invariant UuId of the action to be deleted + * @param servletRequest Servlet request object + * @return Empty response object + */ + @DELETE + @Path("/{actionInvariantUuId}") + @Operation(description = "Delete Action") + Response deleteAction(@PathParam("actionInvariantUuId") String actionInvariantUuId, @Context HttpServletRequest servletRequest); + + /** + * Performs Checkout/Undo_Checkout/Checkin/Submit Operation on Action. + * + * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action + */ + @POST + @Path("/{actionInvariantUuId}") + @Operation(description = "Actions on a action", summary = "Performs one of the following actions on a action: |" + + "Checkout: Locks it for edits by other users. Only the locking user sees the edited " + "version.|" + + "Undo_Checkout: Unlocks it and deletes the edits that were done.|" + "Checkin: Unlocks it and activates the edited version to all users.| " + + "Submit: Finalize its active version.|") + Response actOnAction(@PathParam("actionInvariantUuId") String actionInvariantUuId, String requestJson, + @Context HttpServletRequest servletRequest); + + /** + * Upload an artifact to an action. + * + * @param actionInvariantUuId Invariant UuId of the action to which the artifact is uploaded + * @param artifactName Name of the artifact + * @param artifactLabel Label of the artifact + * @param artifactCategory Category of the artifact + * @param artifactDescription Description of the artifact + * @param artifactProtection Artifact protection mode + * @param checksum Checksum of the artifact + * @param artifactToUpload Artifact content object + * @param servletRequest Servlet request object + * @return Generated UuId of the uploaded artifact + */ + @POST + @Path("/{actionInvariantUuId}/artifacts") + @Consumes(MediaType.MULTIPART_FORM_DATA) + Response uploadArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId, + @Multipart(value = "artifactName", required = false) String artifactName, + @Multipart(value = "artifactLabel", required = false) String artifactLabel, + @Multipart(value = "artifactCategory", required = false) String artifactCategory, + @Multipart(value = "artifactDescription", required = false) String artifactDescription, + @Multipart(value = "artifactProtection", required = false) String artifactProtection, + @HeaderParam("Content-MD5") String checksum, + @Multipart(value = "uploadArtifact", required = false) Attachment artifactToUpload, @Context HttpServletRequest servletRequest); - @DELETE - @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}") - @Operation(description = "Delete Artifact") - Response deleteArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId, - @PathParam("artifactUuId") String artifactUuId, - @Context HttpServletRequest servletRequest); + @GET + @Path("/{actionUuId}/artifacts/{artifactUuId}") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Operation(description = "Downloads artifact for action") + Response downloadArtifact(@PathParam("actionUuId") String actionUuId, @PathParam("artifactUuId") String artifactUuId, + @Context HttpServletRequest servletRequest); - @PUT - @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}") - @Consumes(MediaType.MULTIPART_FORM_DATA) - Response updateArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId, - @PathParam("artifactUuId") String artifactUuId, - @Multipart(value = "artifactName", required = false) String artifactName, - @Multipart(value = "artifactLabel", required = false) String artifactLabel, - @Multipart(value = "artifactCategory", required = false) String artifactCategory, - @Multipart(value = "artifactDescription", required = false) String artifactDescription, - @Multipart(value = "artifactProtection", required = false) String artifactProtection, - @HeaderParam("Content-MD5") String checksum, - @Multipart(value = "updateArtifact", required = false) Attachment artifactToUpdate, - @Context HttpServletRequest servletRequest); + @DELETE + @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}") + @Operation(description = "Delete Artifact") + Response deleteArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId, @PathParam("artifactUuId") String artifactUuId, + @Context HttpServletRequest servletRequest); + @PUT + @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}") + @Consumes(MediaType.MULTIPART_FORM_DATA) + Response updateArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId, @PathParam("artifactUuId") String artifactUuId, + @Multipart(value = "artifactName", required = false) String artifactName, + @Multipart(value = "artifactLabel", required = false) String artifactLabel, + @Multipart(value = "artifactCategory", required = false) String artifactCategory, + @Multipart(value = "artifactDescription", required = false) String artifactDescription, + @Multipart(value = "artifactProtection", required = false) String artifactProtection, + @HeaderParam("Content-MD5") String checksum, + @Multipart(value = "updateArtifact", required = false) Attachment artifactToUpdate, + @Context HttpServletRequest servletRequest); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java index 76ab6f4b88..45d39390a1 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,24 +17,26 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.action.rest; import com.sun.jersey.multipart.FormDataParam; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.apache.cxf.jaxrs.ext.multipart.Multipart; -import org.springframework.validation.annotation.Validated; - +import java.io.InputStream; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +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.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.InputStream; - +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.springframework.validation.annotation.Validated; @Path("/workflow/v1.0/actions") @Produces(MediaType.APPLICATION_JSON) @@ -43,56 +45,43 @@ import java.io.InputStream; @Validated public interface ActionsForSwaggerFileUpload { - /** - * Upload an artifact to an action. - * - * @param actionInvariantUuId Invariant UuId of the action to which the artifact is uploaded - * @param artifactName Name of the artifact - * @param artifactLabel Label of the artifact - * @param artifactCategory Category of the artifact - * @param artifactDescription Description of the artifact - * @param artifactProtection Artifact protection mode - * @param checksum Checksum of the artifact - * @param artifactToUpload Artifact content object - * @param servletRequest Servlet request object - * @return Generated UuId of the uploaded artifact - */ - @POST - @Path("/{actionInvariantUuId}/artifacts") - @Operation(description = "Upload new Artifact") - @Consumes(MediaType.MULTIPART_FORM_DATA) - Response uploadArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId, - @Multipart(value = "artifactName", required = false) String artifactName, - @Multipart(value = "artifactLabel", required = false) - String artifactLabel, - @Multipart(value = "artifactCategory", required = false) - String artifactCategory, - @Multipart(value = "artifactDescription", required = false) - String artifactDescription, - @Multipart(value = "artifactProtection", required = false) - String artifactProtection, - @HeaderParam("Content-MD5") String checksum, - @FormDataParam(value = "uploadArtifact") InputStream artifactToUpload, - @Context HttpServletRequest servletRequest); - - - @PUT - @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}") - @Operation(description = "Update an existing artifact") - @Consumes(MediaType.MULTIPART_FORM_DATA) - Response updateArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId, - @PathParam("artifactUuId") String artifactUuId, - @Multipart(value = "artifactName", required = false) String artifactName, - @Multipart(value = "artifactLabel", required = false) - String artifactLabel, - @Multipart(value = "artifactCategory", required = false) - String artifactCategory, - @Multipart(value = "artifactDescription", required = false) - String artifactDescription, - @Multipart(value = "artifactProtection", required = false) - String artifactProtection, - @HeaderParam("Content-MD5") String checksum, - @FormDataParam(value = "updateArtifact") InputStream artifactToUpdate, - @Context HttpServletRequest servletRequest); + /** + * Upload an artifact to an action. + * + * @param actionInvariantUuId Invariant UuId of the action to which the artifact is uploaded + * @param artifactName Name of the artifact + * @param artifactLabel Label of the artifact + * @param artifactCategory Category of the artifact + * @param artifactDescription Description of the artifact + * @param artifactProtection Artifact protection mode + * @param checksum Checksum of the artifact + * @param artifactToUpload Artifact content object + * @param servletRequest Servlet request object + * @return Generated UuId of the uploaded artifact + */ + @POST + @Path("/{actionInvariantUuId}/artifacts") + @Operation(description = "Upload new Artifact") + @Consumes(MediaType.MULTIPART_FORM_DATA) + Response uploadArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId, + @Multipart(value = "artifactName", required = false) String artifactName, + @Multipart(value = "artifactLabel", required = false) String artifactLabel, + @Multipart(value = "artifactCategory", required = false) String artifactCategory, + @Multipart(value = "artifactDescription", required = false) String artifactDescription, + @Multipart(value = "artifactProtection", required = false) String artifactProtection, + @HeaderParam("Content-MD5") String checksum, @FormDataParam(value = "uploadArtifact") InputStream artifactToUpload, + @Context HttpServletRequest servletRequest); + @PUT + @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}") + @Operation(description = "Update an existing artifact") + @Consumes(MediaType.MULTIPART_FORM_DATA) + Response updateArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId, @PathParam("artifactUuId") String artifactUuId, + @Multipart(value = "artifactName", required = false) String artifactName, + @Multipart(value = "artifactLabel", required = false) String artifactLabel, + @Multipart(value = "artifactCategory", required = false) String artifactCategory, + @Multipart(value = "artifactDescription", required = false) String artifactDescription, + @Multipart(value = "artifactProtection", required = false) String artifactProtection, + @HeaderParam("Content-MD5") String checksum, @FormDataParam(value = "updateArtifact") InputStream artifactToUpdate, + @Context HttpServletRequest servletRequest); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/mapping/MapActionToActionResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/mapping/MapActionToActionResponseDto.java index 9ef1f119f0..c6a97acae0 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/mapping/MapActionToActionResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/mapping/MapActionToActionResponseDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.action.rest.mapping; import org.openecomp.sdc.action.types.Action; @@ -29,13 +28,13 @@ import org.openecomp.sdcrests.mapping.MappingBase; */ public class MapActionToActionResponseDto extends MappingBase<Action, ActionResponseDto> { - @Override - public void doMapping(Action source, ActionResponseDto target) { - target.setActionUuId(source.getActionUuId()); - target.setActionInvariantUuId(source.getActionInvariantUuId()); - target.setVersion(source.getVersion()); - if (source.getStatus() != null) { - target.setStatus(source.getStatus().name()); + @Override + public void doMapping(Action source, ActionResponseDto target) { + target.setActionUuId(source.getActionUuId()); + target.setActionInvariantUuId(source.getActionInvariantUuId()); + target.setVersion(source.getVersion()); + if (source.getStatus() != null) { + target.setStatus(source.getStatus().name()); + } } - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java index 12a3aa564a..7a60ce705e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,7 +19,6 @@ * Modifications copyright (c) 2019 Nokia * ================================================================================ */ - package org.openecomp.sdcrests.action.rest.services; import static org.onap.logging.ref.slf4j.ONAPLogConstants.ResponseStatus.COMPLETE; @@ -104,7 +103,9 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; - +import javax.inject.Named; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Response; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; import org.apache.cxf.jaxrs.ext.multipart.Attachment; @@ -134,10 +135,6 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import javax.inject.Named; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Response; - /** * Implements various CRUD API that can be performed on Action */ @@ -148,1070 +145,944 @@ import javax.ws.rs.core.Response; @Validated public class ActionsImpl implements Actions { - private static final Logger LOGGER = LoggerFactory.getLogger(ActionsImpl.class); - - private final ActionManager actionManager; - - private String whitespaceCharacters = "\\s" /* dummy empty string for homogeneity */ - + "\\u0009" // CHARACTER TABULATION - + "\\u000A" // LINE FEED (LF) - + "\\u000B" // LINE TABULATION - + "\\u000C" // FORM FEED (FF) - + "\\u000D" // CARRIAGE RETURN (CR) - + "\\u0020" // SPACE - + "\\u0085" // NEXT LINE (NEL) - + "\\u00A0" // NO-BREAK SPACE - + "\\u1680" // OGHAM SPACE MARK - + "\\u180E" // MONGOLIAN VOWEL SEPARATOR - + "\\u2000" // EN QUAD - + "\\u2001" // EM QUAD - + "\\u2002" // EN SPACE - + "\\u2003" // EM SPACE - + "\\u2004" // THREE-PER-EM SPACE - + "\\u2005" // FOUR-PER-EM SPACE - + "\\u2006" // SIX-PER-EM SPACE - + "\\u2007" // FIGURE SPACE - + "\\u2008" // PUNCTUATION SPACE - + "\\u2009" // THIN SPACE - + "\\u200A" // HAIR SPACE - + "\\u2028" // LINE SEPARATOR - + "\\u2029" // PARAGRAPH SEPARATOR - + "\\u202F" // NARROW NO-BREAK SPACE - + "\\u205F" // MEDIUM MATHEMATICAL SPACE - + "\\u3000" // IDEOGRAPHIC SPACE - ; - private String invalidFilenameChars = "#<>$+%!`&*'|{}?\"=/:@\\\\"; - private String whitespaceRegex = ".*[" + whitespaceCharacters + "].*"; - private String invalidFilenameRegex = ".*[" + whitespaceCharacters + invalidFilenameChars + "].*"; - - @Autowired - public ActionsImpl(ActionManager actionManager) { - this.actionManager = actionManager; - } - - /** - * Calculate the checksum for a given input - * - * @param input Byte array for which the checksum has to be calculated - * @return Calculated checksum of the input byte array - */ - private static String calculateCheckSum(byte[] input) { - String checksum = null; - if (input != null) { - checksum = DigestUtils.md5Hex(input); - } - return checksum; - } - - @Override - public Response getActionsByActionInvariantUuId(String invariantID, String actionUUID, - HttpServletRequest servletRequest) { - ListResponseWrapper responseList = new ListResponseWrapper(); - - try { - LOGGER.debug(" entering getActionsByActionInvariantUuId "); - initializeRequestMDC(servletRequest, invariantID, ActionRequest.GET_ACTIONS_INVARIANT_ID); - MDC.put(SERVICE_INSTANCE_ID, invariantID); - - if (StringUtils.isEmpty(servletRequest.getQueryString())) { - responseList = getActionsByInvId(servletRequest, invariantID); - } else { - Response response = getActionByUUID(servletRequest, invariantID, actionUUID); - actionLogPostProcessor(COMPLETE, true); - return response; - } - } catch (ActionException exception) { - actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - LOGGER.error(""); - throw exception; - } catch (Exception exception) { - actionLogPostProcessor(ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, - ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - LOGGER.error(""); - throw exception; + private static final Logger LOGGER = LoggerFactory.getLogger(ActionsImpl.class); + private final ActionManager actionManager; + private String whitespaceCharacters = "\\s" /* dummy empty string for homogeneity */ + + "\\u0009" // CHARACTER TABULATION + + "\\u000A" // LINE FEED (LF) + + "\\u000B" // LINE TABULATION + + "\\u000C" // FORM FEED (FF) + + "\\u000D" // CARRIAGE RETURN (CR) + + "\\u0020" // SPACE + + "\\u0085" // NEXT LINE (NEL) + + "\\u00A0" // NO-BREAK SPACE + + "\\u1680" // OGHAM SPACE MARK + + "\\u180E" // MONGOLIAN VOWEL SEPARATOR + + "\\u2000" // EN QUAD + + "\\u2001" // EM QUAD + + "\\u2002" // EN SPACE + + "\\u2003" // EM SPACE + + "\\u2004" // THREE-PER-EM SPACE + + "\\u2005" // FOUR-PER-EM SPACE + + "\\u2006" // SIX-PER-EM SPACE + + "\\u2007" // FIGURE SPACE + + "\\u2008" // PUNCTUATION SPACE + + "\\u2009" // THIN SPACE + + "\\u200A" // HAIR SPACE + + "\\u2028" // LINE SEPARATOR + + "\\u2029" // PARAGRAPH SEPARATOR + + "\\u202F" // NARROW NO-BREAK SPACE + + "\\u205F" // MEDIUM MATHEMATICAL SPACE + + "\\u3000" // IDEOGRAPHIC SPACE + ; + private String invalidFilenameChars = "#<>$+%!`&*'|{}?\"=/:@\\\\"; + private String whitespaceRegex = ".*[" + whitespaceCharacters + "].*"; + private String invalidFilenameRegex = ".*[" + whitespaceCharacters + invalidFilenameChars + "].*"; + + @Autowired + public ActionsImpl(ActionManager actionManager) { + this.actionManager = actionManager; } - LOGGER.debug(" exit getActionsByActionInvariantUuId "); - actionLogPostProcessor(COMPLETE, true); - return Response.ok(responseList).build(); - } - - private ListResponseWrapper getActionsByInvId(HttpServletRequest servletRequest, - String invariantID) { - LOGGER.debug(" entering getActionsByInvId with invariantID= " + invariantID); - ListResponseWrapper responseList = new ListResponseWrapper(); - if (StringUtils.isEmpty(servletRequest.getQueryString())) { - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - Map<String, String> queryParamErrors = validateQueryParam(invariantID); - errorMap.putAll(queryParamErrors); - if (errorMap.isEmpty()) { - List<Action> actions = actionManager.getActionsByActionInvariantUuId(invariantID); - List<ActionResponseDto> versionList = new ArrayList<>(); - for (Action action : actions) { - ActionResponseDto responseDTO = createResponseDTO(action); - versionList.add(responseDTO); + /** + * Calculate the checksum for a given input + * + * @param input Byte array for which the checksum has to be calculated + * @return Calculated checksum of the input byte array + */ + private static String calculateCheckSum(byte[] input) { + String checksum = null; + if (input != null) { + checksum = DigestUtils.md5Hex(input); } - responseList.setVersions(versionList); - responseList.setActionList(null); - - } else { - checkAndThrowError(errorMap); - } - } - LOGGER.debug(" exit getActionsByInvId with invariantID= " + invariantID); - return responseList; - } - - private Response getActionByUUID(HttpServletRequest servletRequest, String invariantID, - String actionUUID) throws ActionException { - int noOfFilterParams = 0; - Response response = null; - LOGGER.debug(" entering getActionByUUID with invariantID= " + invariantID + " and actionUUID= " + - actionUUID); - if (!StringUtils.isEmpty(actionUUID)) { - noOfFilterParams++; - response = getActionsByUniqueID(actionUUID, servletRequest, invariantID); - } - if (noOfFilterParams == 0) { - throw new ActionException(ACTION_INVALID_SEARCH_CRITERIA, - ACTION_REQUEST_FILTER_PARAM_INVALID); - } - - LOGGER.debug(" exit getActionByUUID with invariantID= " + invariantID + " and actionUUID= " + - actionUUID); - return response; - } - - @Override - public Response getOpenEcompComponents(HttpServletRequest servletRequest) { - try { - LOGGER.debug(" entering getEcompComponents "); - initializeRequestMDC(servletRequest, "", ActionRequest.GET_OPEN_ECOMP_COMPONENTS); - //Validate request syntax before passing to the manager - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - checkAndThrowError(errorMap); - ListResponseWrapper response = new ListResponseWrapper(); - List<OpenEcompComponent> openEcompComponents = actionManager.getOpenEcompComponents(); - response.setActionList(null); - response.setComponentList(openEcompComponents); - LOGGER.debug(" exit getEcompComponents "); - actionLogPostProcessor(COMPLETE, true); - return Response.ok(response).build(); - } catch (ActionException exception) { - actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - LOGGER.error(""); - throw exception; - } catch (Exception exception) { - actionLogPostProcessor(ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, - ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - LOGGER.error(""); - throw exception; + return checksum; } - } - @Override - public Response getFilteredActions(String vendor, String category, String name, String modelID, - String componentID, HttpServletRequest servletRequest) { - try { - LOGGER.debug(" entering getFilteredActions "); - Response response; - initializeRequestMDC(servletRequest, "", ActionRequest.GET_FILTERED_ACTIONS); - int noOfFilterParams = getNoOfFilterParams(vendor, category, name, modelID, componentID); - if (StringUtils.isEmpty(servletRequest.getQueryString())) { - response = getAllActions(servletRequest); - LOGGER.debug(" exit getFilteredActions "); + @Override + public Response getActionsByActionInvariantUuId(String invariantID, String actionUUID, HttpServletRequest servletRequest) { + ListResponseWrapper responseList = new ListResponseWrapper(); + try { + LOGGER.debug(" entering getActionsByActionInvariantUuId "); + initializeRequestMDC(servletRequest, invariantID, ActionRequest.GET_ACTIONS_INVARIANT_ID); + MDC.put(SERVICE_INSTANCE_ID, invariantID); + if (StringUtils.isEmpty(servletRequest.getQueryString())) { + responseList = getActionsByInvId(servletRequest, invariantID); + } else { + Response response = getActionByUUID(servletRequest, invariantID, actionUUID); + actionLogPostProcessor(COMPLETE, true); + return response; + } + } catch (ActionException exception) { + actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); + LOGGER.error(""); + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + LOGGER.error(""); + throw exception; + } + LOGGER.debug(" exit getActionsByActionInvariantUuId "); actionLogPostProcessor(COMPLETE, true); - return response; - } - validateNoOfFilterParamsExactly1(noOfFilterParams); - if (!StringUtils.isEmpty(vendor)) { - response = getActionsByVendor(vendor, servletRequest); - } else if (!StringUtils.isEmpty(category)) { - response = getActionsByCategory(category, servletRequest); - } else if (!StringUtils.isEmpty(name)) { - response = getActionsByName(name, servletRequest); - } else if (!StringUtils.isEmpty(modelID)) { - response = getActionsByModel(modelID, servletRequest); - } else if (!StringUtils.isEmpty(componentID)) { - response = getActionsByOpenEcompComponents(componentID, servletRequest); - } else { - throw new ActionException(ACTION_INVALID_PARAM_CODE, ACTION_REQUEST_FILTER_PARAM_INVALID); - } - - LOGGER.debug(" exit getFilteredActions "); - actionLogPostProcessor(COMPLETE, true); - return response; - } catch (ActionException exception) { - actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - LOGGER.error(""); - throw exception; - } catch (Exception exception) { - actionLogPostProcessor(ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, - ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - LOGGER.error(""); - throw exception; + return Response.ok(responseList).build(); } - } - private void validateNoOfFilterParamsExactly1(int noOfFilterParams) { - if (noOfFilterParams > 1) { - throw new ActionException(ACTION_MULT_SEARCH_CRITERIA, - ACTION_FILTER_MULTIPLE_QUERY_PARAM_NOT_SUPPORTED); - } - if (noOfFilterParams == 0) { - throw new ActionException(ACTION_INVALID_SEARCH_CRITERIA, - ACTION_REQUEST_FILTER_PARAM_INVALID); - } - } - - private int getNoOfFilterParams(String vendor, String category, String name, String modelID, String componentID) { - int noOfFilterParams = 0; - if (!StringUtils.isEmpty(vendor)) { - noOfFilterParams++; - } - if (!StringUtils.isEmpty(category)) { - noOfFilterParams++; - } - if (!StringUtils.isEmpty(name)) { - noOfFilterParams++; - } - if (!StringUtils.isEmpty(modelID)) { - noOfFilterParams++; - } - if (!StringUtils.isEmpty(componentID)) { - noOfFilterParams++; - } - return noOfFilterParams; - } - - @Override - public Response createAction(String requestJSON, HttpServletRequest servletRequest) { - try { - initializeRequestMDC(servletRequest, null, ActionRequest.CREATE_ACTION); - LOGGER.debug(" entering API createAction "); - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - Map<String, String> requestBodyErrors = - validateRequestBody(REQUEST_TYPE_CREATE_ACTION, requestJSON); - errorMap.putAll(requestBodyErrors); - ActionResponseDto actionResponseDTO = new ActionResponseDto(); - if (errorMap.isEmpty()) { - String user = servletRequest.getRemoteUser(); - Action action = JsonUtil.json2Object(requestJSON, Action.class); - action.setData(requestJSON); - Action responseAction = actionManager.createAction(action, user); - MDC.put(SERVICE_INSTANCE_ID, responseAction.getActionInvariantUuId()); - new MapActionToActionResponseDto().doMapping(responseAction, actionResponseDTO); - } else { - checkAndThrowError(errorMap); - } - actionLogPostProcessor(COMPLETE, true); - LOGGER.debug(" exit API createAction with ActionInvariantUUID= " + MDC.get(SERVICE_INSTANCE_ID)); - return Response.ok(actionResponseDTO).build(); - } catch (ActionException exception) { - actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - LOGGER.error(""); - throw exception; - } catch (Exception exception) { - actionLogPostProcessor(ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, - ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - LOGGER.error(exception.getMessage()); - throw exception; - } - - } - - @Override - public Response updateAction(String invariantUUID, String requestJSON, - HttpServletRequest servletRequest) { - ActionResponseDto actionResponseDTO = null; - try { - initializeRequestMDC(servletRequest, invariantUUID, ActionRequest.UPDATE_ACTION); - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - Map<String, String> requestBodyErrors = - validateRequestBody(REQUEST_TYPE_UPDATE_ACTION, requestJSON); - errorMap.putAll(requestBodyErrors); - actionResponseDTO = new ActionResponseDto(); - if (errorMap.isEmpty()) { - String user = servletRequest.getRemoteUser(); - Action action = JsonUtil.json2Object(requestJSON, Action.class); - action.setActionInvariantUuId(invariantUUID); - action.setData(requestJSON); - Action updatedAction = actionManager.updateAction(action, user); - new MapActionToActionResponseDto().doMapping(updatedAction, actionResponseDTO); - } else { - checkAndThrowError(errorMap); - } - actionLogPostProcessor(COMPLETE, true); - } catch (ActionException exception) { - actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - LOGGER.error(""); - throw exception; - } catch (Exception exception) { - actionLogPostProcessor(ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, - ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - LOGGER.error(exception.getMessage()); - throw exception; - } - - return Response.ok(actionResponseDTO).build(); - } - - @Override - public Response deleteAction(String actionInvariantUUID, HttpServletRequest servletRequest) { - try { - initializeRequestMDC(servletRequest, actionInvariantUUID, ActionRequest.DELETE_ACTION); - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - if (errorMap.isEmpty()) { - String user = servletRequest.getRemoteUser(); - actionManager.deleteAction(actionInvariantUUID, user); - } else { - checkAndThrowError(errorMap); - } - - actionLogPostProcessor(COMPLETE, true); - return Response.ok(new ActionResponseDto()).build(); - } catch (ActionException exception) { - actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - LOGGER.error(MDC.get(ERROR_DESCRIPTION)); - throw exception; - } catch (Exception exception) { - actionLogPostProcessor(ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, - ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - LOGGER.error(exception.getMessage()); - throw exception; - } - } - - @Override - public Response actOnAction(String invariantUUID, String requestJSON, - HttpServletRequest servletRequest) { - Response response = null; - try { - initializeRequestMDC(servletRequest, invariantUUID, ActionRequest.ACTION_VERSIONING); - LOGGER.debug("entering actOnAction with invariantUUID= " + invariantUUID + " and requestJSON= " + - requestJSON); - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - Map<String, String> requestBodyErrors = - validateRequestBody(REQUEST_TYPE_VERSION_ACTION, requestJSON); - errorMap.putAll(requestBodyErrors); - - ActionVersionDto versionDTO = JsonUtil.json2Object(requestJSON, ActionVersionDto.class); - checkAndThrowError(errorMap); - - String status = versionDTO.getStatus(); - Action action = new Action(); - String user = servletRequest.getRemoteUser(); - switch (status) { - case "Checkout": - action = actionManager.checkout(invariantUUID, user); - break; - case "Undo_Checkout": - actionManager.undoCheckout(invariantUUID, user); - StringWrapperResponse responseText = new StringWrapperResponse(); - responseText.setValue(ActionConstants.UNDO_CHECKOUT_RESPONSE_TEXT); - response = Response - .status(Response.Status.OK) - .entity(responseText) - .build(); - return response; - case "Checkin": - action = actionManager.checkin(invariantUUID, user); - break; - case "Submit": - action = actionManager.submit(invariantUUID, user); - break; - default: - throw new ActionException(ACTION_INVALID_PARAM_CODE, - String.format(ACTION_UNSUPPORTED_OPERATION, status)); - } - - ActionResponseDto actionResponseDTO = new ActionResponseDto(); - new MapActionToActionResponseDto().doMapping(action, actionResponseDTO); - response = Response.ok(actionResponseDTO).build(); - actionLogPostProcessor(COMPLETE, true); - } catch (ActionException exception) { - actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - LOGGER.error(MDC.get(ERROR_DESCRIPTION)); - throw exception; - } catch (Exception exception) { - actionLogPostProcessor(ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, - ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - LOGGER.error(exception.getMessage()); - throw exception; - } finally { - LOGGER.debug("exit actOnAction with invariantUUID= " + invariantUUID + " and requestJSON= " + - requestJSON); - } - return response; - } - - @Override - public Response uploadArtifact(String actionInvariantUUID, - String artifactName, - String artifactLabel, - String artifactCategory, - String artifactDescription, - String artifactProtection, - String checksum, - Attachment artifactToUpload, - HttpServletRequest servletRequest) { - Response response = null; - try { - initializeRequestMDC(servletRequest, actionInvariantUUID, ActionRequest.UPLOAD_ARTIFACT); - LOGGER.debug("entering uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + - "artifactName= " + artifactName); - response = - uploadArtifactInternal(actionInvariantUUID, artifactName, artifactLabel, artifactCategory, - artifactDescription, artifactProtection, checksum, artifactToUpload, servletRequest); - actionLogPostProcessor(COMPLETE, true); - LOGGER.debug("exiting uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + - "artifactName= " + artifactName); - } catch (ActionException exception) { - actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - LOGGER.error(MDC.get(ERROR_DESCRIPTION)); - throw exception; - } catch (Exception exception) { - actionLogPostProcessor(ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, - ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - LOGGER.error(exception.getMessage()); - throw exception; + private ListResponseWrapper getActionsByInvId(HttpServletRequest servletRequest, String invariantID) { + LOGGER.debug(" entering getActionsByInvId with invariantID= " + invariantID); + ListResponseWrapper responseList = new ListResponseWrapper(); + if (StringUtils.isEmpty(servletRequest.getQueryString())) { + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + Map<String, String> queryParamErrors = validateQueryParam(invariantID); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + List<Action> actions = actionManager.getActionsByActionInvariantUuId(invariantID); + List<ActionResponseDto> versionList = new ArrayList<>(); + for (Action action : actions) { + ActionResponseDto responseDTO = createResponseDTO(action); + versionList.add(responseDTO); + } + responseList.setVersions(versionList); + responseList.setActionList(null); + } else { + checkAndThrowError(errorMap); + } + } + LOGGER.debug(" exit getActionsByInvId with invariantID= " + invariantID); + return responseList; } - LOGGER.debug("exiting uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + - "artifactName= " + artifactName); - return response; - } - - private Response uploadArtifactInternal(String actionInvariantUUID, String artifactName, - String artifactLabel, String artifactCategory, - String artifactDescription, String artifactProtection, - String checksum, Attachment artifactToUpload, - HttpServletRequest servletRequest) { - byte[] payload = null; - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - //Artifact name empty validation - if (StringUtils.isEmpty(artifactName)) { - errorMap.put(ACTION_REQUEST_INVALID_GENERIC_CODE, - ACTION_REQUEST_MISSING_MANDATORY_PARAM + ARTIFACT_NAME); - } else { - //Artifact name syntax check for whitespaces and invalid characters - if (artifactName.matches(invalidFilenameRegex)) { - errorMap.put(ACTION_ARTIFACT_INVALID_NAME_CODE, ACTION_ARTIFACT_INVALID_NAME); - } + private Response getActionByUUID(HttpServletRequest servletRequest, String invariantID, String actionUUID) throws ActionException { + int noOfFilterParams = 0; + Response response = null; + LOGGER.debug(" entering getActionByUUID with invariantID= " + invariantID + " and actionUUID= " + actionUUID); + if (!StringUtils.isEmpty(actionUUID)) { + noOfFilterParams++; + response = getActionsByUniqueID(actionUUID, servletRequest, invariantID); + } + if (noOfFilterParams == 0) { + throw new ActionException(ACTION_INVALID_SEARCH_CRITERIA, ACTION_REQUEST_FILTER_PARAM_INVALID); + } + LOGGER.debug(" exit getActionByUUID with invariantID= " + invariantID + " and actionUUID= " + actionUUID); + return response; } - //Content-Type Header Validation - String contentType = servletRequest.getContentType(); - if (StringUtils.isEmpty(contentType)) { - errorMap.put(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_CONTENT_TYPE_INVALID); + @Override + public Response getOpenEcompComponents(HttpServletRequest servletRequest) { + try { + LOGGER.debug(" entering getEcompComponents "); + initializeRequestMDC(servletRequest, "", ActionRequest.GET_OPEN_ECOMP_COMPONENTS); + //Validate request syntax before passing to the manager + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + checkAndThrowError(errorMap); + ListResponseWrapper response = new ListResponseWrapper(); + List<OpenEcompComponent> openEcompComponents = actionManager.getOpenEcompComponents(); + response.setActionList(null); + response.setComponentList(openEcompComponents); + LOGGER.debug(" exit getEcompComponents "); + actionLogPostProcessor(COMPLETE, true); + return Response.ok(response).build(); + } catch (ActionException exception) { + actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); + LOGGER.error(""); + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + LOGGER.error(""); + throw exception; + } } - if (artifactToUpload == null) { - throw new ActionException(ACTION_REQUEST_INVALID_GENERIC_CODE, - ACTION_REQUEST_MISSING_MANDATORY_PARAM + ARTIFACT_FILE); + @Override + public Response getFilteredActions(String vendor, String category, String name, String modelID, String componentID, + HttpServletRequest servletRequest) { + try { + LOGGER.debug(" entering getFilteredActions "); + Response response; + initializeRequestMDC(servletRequest, "", ActionRequest.GET_FILTERED_ACTIONS); + int noOfFilterParams = getNoOfFilterParams(vendor, category, name, modelID, componentID); + if (StringUtils.isEmpty(servletRequest.getQueryString())) { + response = getAllActions(servletRequest); + LOGGER.debug(" exit getFilteredActions "); + actionLogPostProcessor(COMPLETE, true); + return response; + } + validateNoOfFilterParamsExactly1(noOfFilterParams); + if (!StringUtils.isEmpty(vendor)) { + response = getActionsByVendor(vendor, servletRequest); + } else if (!StringUtils.isEmpty(category)) { + response = getActionsByCategory(category, servletRequest); + } else if (!StringUtils.isEmpty(name)) { + response = getActionsByName(name, servletRequest); + } else if (!StringUtils.isEmpty(modelID)) { + response = getActionsByModel(modelID, servletRequest); + } else if (!StringUtils.isEmpty(componentID)) { + response = getActionsByOpenEcompComponents(componentID, servletRequest); + } else { + throw new ActionException(ACTION_INVALID_PARAM_CODE, ACTION_REQUEST_FILTER_PARAM_INVALID); + } + LOGGER.debug(" exit getFilteredActions "); + actionLogPostProcessor(COMPLETE, true); + return response; + } catch (ActionException exception) { + actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); + LOGGER.error(""); + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + LOGGER.error(""); + throw exception; + } } - try (InputStream artifactInputStream = artifactToUpload.getDataHandler().getInputStream()) { - payload = FileUtils.toByteArray(artifactInputStream); - } catch (IOException exception) { - LOGGER.error(ACTION_ARTIFACT_READ_FILE_ERROR, exception); - throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ARTIFACT_READ_FILE_ERROR); + private void validateNoOfFilterParamsExactly1(int noOfFilterParams) { + if (noOfFilterParams > 1) { + throw new ActionException(ACTION_MULT_SEARCH_CRITERIA, ACTION_FILTER_MULTIPLE_QUERY_PARAM_NOT_SUPPORTED); + } + if (noOfFilterParams == 0) { + throw new ActionException(ACTION_INVALID_SEARCH_CRITERIA, ACTION_REQUEST_FILTER_PARAM_INVALID); + } } - //Validate Artifact size - if (payload != null && payload.length > MAX_ACTION_ARTIFACT_SIZE) { - throw new ActionException(ACTION_ARTIFACT_TOO_BIG_ERROR_CODE, ACTION_ARTIFACT_TOO_BIG_ERROR); + private int getNoOfFilterParams(String vendor, String category, String name, String modelID, String componentID) { + int noOfFilterParams = 0; + if (!StringUtils.isEmpty(vendor)) { + noOfFilterParams++; + } + if (!StringUtils.isEmpty(category)) { + noOfFilterParams++; + } + if (!StringUtils.isEmpty(name)) { + noOfFilterParams++; + } + if (!StringUtils.isEmpty(modelID)) { + noOfFilterParams++; + } + if (!StringUtils.isEmpty(componentID)) { + noOfFilterParams++; + } + return noOfFilterParams; } - //Validate Checksum - if (StringUtils.isEmpty(checksum) || !checksum.equalsIgnoreCase(calculateCheckSum(payload))) { - errorMap.put(ACTION_ARTIFACT_CHECKSUM_ERROR_CODE, ACTION_REQUEST_ARTIFACT_CHECKSUM_ERROR); + @Override + public Response createAction(String requestJSON, HttpServletRequest servletRequest) { + try { + initializeRequestMDC(servletRequest, null, ActionRequest.CREATE_ACTION); + LOGGER.debug(" entering API createAction "); + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + Map<String, String> requestBodyErrors = validateRequestBody(REQUEST_TYPE_CREATE_ACTION, requestJSON); + errorMap.putAll(requestBodyErrors); + ActionResponseDto actionResponseDTO = new ActionResponseDto(); + if (errorMap.isEmpty()) { + String user = servletRequest.getRemoteUser(); + Action action = JsonUtil.json2Object(requestJSON, Action.class); + action.setData(requestJSON); + Action responseAction = actionManager.createAction(action, user); + MDC.put(SERVICE_INSTANCE_ID, responseAction.getActionInvariantUuId()); + new MapActionToActionResponseDto().doMapping(responseAction, actionResponseDTO); + } else { + checkAndThrowError(errorMap); + } + actionLogPostProcessor(COMPLETE, true); + LOGGER.debug(" exit API createAction with ActionInvariantUUID= " + MDC.get(SERVICE_INSTANCE_ID)); + return Response.ok(actionResponseDTO).build(); + } catch (ActionException exception) { + actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); + LOGGER.error(""); + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + LOGGER.error(exception.getMessage()); + throw exception; + } } - //Validate artifact protection values - if (StringUtils.isEmpty(artifactProtection)) { - artifactProtection = ActionArtifactProtection.readWrite.name(); + @Override + public Response updateAction(String invariantUUID, String requestJSON, HttpServletRequest servletRequest) { + ActionResponseDto actionResponseDTO = null; + try { + initializeRequestMDC(servletRequest, invariantUUID, ActionRequest.UPDATE_ACTION); + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + Map<String, String> requestBodyErrors = validateRequestBody(REQUEST_TYPE_UPDATE_ACTION, requestJSON); + errorMap.putAll(requestBodyErrors); + actionResponseDTO = new ActionResponseDto(); + if (errorMap.isEmpty()) { + String user = servletRequest.getRemoteUser(); + Action action = JsonUtil.json2Object(requestJSON, Action.class); + action.setActionInvariantUuId(invariantUUID); + action.setData(requestJSON); + Action updatedAction = actionManager.updateAction(action, user); + new MapActionToActionResponseDto().doMapping(updatedAction, actionResponseDTO); + } else { + checkAndThrowError(errorMap); + } + actionLogPostProcessor(COMPLETE, true); + } catch (ActionException exception) { + actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); + LOGGER.error(""); + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + LOGGER.error(exception.getMessage()); + throw exception; + } + return Response.ok(actionResponseDTO).build(); } - if (!artifactProtection.equals(ActionArtifactProtection.readOnly.name()) && - !artifactProtection.equals(ActionArtifactProtection.readWrite.name())) { - errorMap.put(ACTION_ARTIFACT_INVALID_PROTECTION_CODE, - ACTION_REQUEST_ARTIFACT_INVALID_PROTECTION_VALUE); + @Override + public Response deleteAction(String actionInvariantUUID, HttpServletRequest servletRequest) { + try { + initializeRequestMDC(servletRequest, actionInvariantUUID, ActionRequest.DELETE_ACTION); + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + if (errorMap.isEmpty()) { + String user = servletRequest.getRemoteUser(); + actionManager.deleteAction(actionInvariantUUID, user); + } else { + checkAndThrowError(errorMap); + } + actionLogPostProcessor(COMPLETE, true); + return Response.ok(new ActionResponseDto()).build(); + } catch (ActionException exception) { + actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); + LOGGER.error(MDC.get(ERROR_DESCRIPTION)); + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + LOGGER.error(exception.getMessage()); + throw exception; + } } - ActionArtifact uploadedArtifact = new ActionArtifact(); - if (errorMap.isEmpty()) { - String user = servletRequest.getRemoteUser(); - ActionArtifact upload = new ActionArtifact(); - upload.setArtifactName(artifactName); - upload.setArtifactLabel(artifactLabel); - upload.setArtifactDescription(artifactDescription); - upload.setArtifact(payload); - upload.setArtifactCategory(artifactCategory); - upload.setArtifactProtection(artifactProtection); - uploadedArtifact = actionManager.uploadArtifact(upload, actionInvariantUUID, user); - } else { - checkAndThrowError(errorMap); + @Override + public Response actOnAction(String invariantUUID, String requestJSON, HttpServletRequest servletRequest) { + Response response = null; + try { + initializeRequestMDC(servletRequest, invariantUUID, ActionRequest.ACTION_VERSIONING); + LOGGER.debug("entering actOnAction with invariantUUID= " + invariantUUID + " and requestJSON= " + requestJSON); + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + Map<String, String> requestBodyErrors = validateRequestBody(REQUEST_TYPE_VERSION_ACTION, requestJSON); + errorMap.putAll(requestBodyErrors); + ActionVersionDto versionDTO = JsonUtil.json2Object(requestJSON, ActionVersionDto.class); + checkAndThrowError(errorMap); + String status = versionDTO.getStatus(); + Action action = new Action(); + String user = servletRequest.getRemoteUser(); + switch (status) { + case "Checkout": + action = actionManager.checkout(invariantUUID, user); + break; + case "Undo_Checkout": + actionManager.undoCheckout(invariantUUID, user); + StringWrapperResponse responseText = new StringWrapperResponse(); + responseText.setValue(ActionConstants.UNDO_CHECKOUT_RESPONSE_TEXT); + response = Response.status(Response.Status.OK).entity(responseText).build(); + return response; + case "Checkin": + action = actionManager.checkin(invariantUUID, user); + break; + case "Submit": + action = actionManager.submit(invariantUUID, user); + break; + default: + throw new ActionException(ACTION_INVALID_PARAM_CODE, String.format(ACTION_UNSUPPORTED_OPERATION, status)); + } + ActionResponseDto actionResponseDTO = new ActionResponseDto(); + new MapActionToActionResponseDto().doMapping(action, actionResponseDTO); + response = Response.ok(actionResponseDTO).build(); + actionLogPostProcessor(COMPLETE, true); + } catch (ActionException exception) { + actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); + LOGGER.error(MDC.get(ERROR_DESCRIPTION)); + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + LOGGER.error(exception.getMessage()); + throw exception; + } finally { + LOGGER.debug("exit actOnAction with invariantUUID= " + invariantUUID + " and requestJSON= " + requestJSON); + } + return response; } - return Response.ok(uploadedArtifact).build(); - } - @Override - public Response downloadArtifact(String actionUUID, String artifactUUID, + @Override + public Response uploadArtifact(String actionInvariantUUID, String artifactName, String artifactLabel, String artifactCategory, + String artifactDescription, String artifactProtection, String checksum, Attachment artifactToUpload, HttpServletRequest servletRequest) { - Response response = null; - try { - initializeRequestMDC(servletRequest, "", ActionRequest.DOWNLOAD_ARTIFACT); - LOGGER.debug( - " entering downloadArtifact with actionUUID= " + actionUUID + " and artifactUUID= " + - artifactUUID); - response = downloadArtifactInternal(actionUUID, artifactUUID, servletRequest); - actionLogPostProcessor(COMPLETE, true); - } catch (ActionException exception) { - actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - LOGGER.error(MDC.get(ERROR_DESCRIPTION)); - throw exception; - } catch (Exception exception) { - actionLogPostProcessor(ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, - ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - LOGGER.error(exception.getMessage()); - throw exception; + Response response = null; + try { + initializeRequestMDC(servletRequest, actionInvariantUUID, ActionRequest.UPLOAD_ARTIFACT); + LOGGER.debug("entering uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + "artifactName= " + artifactName); + response = uploadArtifactInternal(actionInvariantUUID, artifactName, artifactLabel, artifactCategory, artifactDescription, + artifactProtection, checksum, artifactToUpload, servletRequest); + actionLogPostProcessor(COMPLETE, true); + LOGGER.debug("exiting uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + "artifactName= " + artifactName); + } catch (ActionException exception) { + actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); + LOGGER.error(MDC.get(ERROR_DESCRIPTION)); + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + LOGGER.error(exception.getMessage()); + throw exception; + } + LOGGER.debug("exiting uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + "artifactName= " + artifactName); + return response; } - LOGGER.debug(" exit downloadArtifact with actionUUID= " + actionUUID + " and artifactUUID= " + - artifactUUID); - return response; - } - - private Response downloadArtifactInternal(String actionUUID, String artifactUUID, + private Response uploadArtifactInternal(String actionInvariantUUID, String artifactName, String artifactLabel, String artifactCategory, + String artifactDescription, String artifactProtection, String checksum, Attachment artifactToUpload, HttpServletRequest servletRequest) { - Response response; - ActionArtifact actionartifact = null; - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - Map<String, String> queryParamErrors = validateQueryParam(actionUUID); - errorMap.putAll(queryParamErrors); - queryParamErrors = validateQueryParam(artifactUUID); - errorMap.putAll(queryParamErrors); - if (errorMap.isEmpty()) { - actionartifact = actionManager.downloadArtifact(actionUUID, artifactUUID); - } else { - checkAndThrowError(errorMap); - } - response = createArtifactDownloadResponse(actionartifact); - return response; - } - - @Override - public Response deleteArtifact(String actionInvariantUUID, String artifactUUID, - HttpServletRequest servletRequest) { - Response response = null; - try { - initializeRequestMDC(servletRequest, actionInvariantUUID, ActionRequest.DELETE_ARTIFACT); - LOGGER.debug(" entering deleteArtifact with actionInvariantUuId= " + actionInvariantUUID + - " and artifactUUID= " + artifactUUID); - response = deleteArtifactInternal(actionInvariantUUID, artifactUUID, servletRequest); - LOGGER.debug(" exit deleteArtifact with actionInvariantUuId= " + actionInvariantUUID + - " and artifactUUID= " + artifactUUID); - actionLogPostProcessor(COMPLETE, true); - } catch (ActionException exception) { - actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - LOGGER.error(MDC.get(ERROR_DESCRIPTION)); - throw exception; - } catch (Exception exception) { - actionLogPostProcessor(ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, - ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - LOGGER.error(exception.getMessage()); - throw exception; - } - - return response; - } - - private Response deleteArtifactInternal(String actionInvariantUUID, String artifactUUID, - HttpServletRequest servletRequest) { - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - Map<String, String> queryParamErrors = validateQueryParam(actionInvariantUUID); - errorMap.putAll(queryParamErrors); - queryParamErrors = validateQueryParam(artifactUUID); - errorMap.putAll(queryParamErrors); - if (errorMap.isEmpty()) { - actionManager - .deleteArtifact(actionInvariantUUID, artifactUUID, servletRequest.getRemoteUser()); - } else { - checkAndThrowError(errorMap); + byte[] payload = null; + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + //Artifact name empty validation + if (StringUtils.isEmpty(artifactName)) { + errorMap.put(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_MISSING_MANDATORY_PARAM + ARTIFACT_NAME); + } else { + //Artifact name syntax check for whitespaces and invalid characters + if (artifactName.matches(invalidFilenameRegex)) { + errorMap.put(ACTION_ARTIFACT_INVALID_NAME_CODE, ACTION_ARTIFACT_INVALID_NAME); + } + } + //Content-Type Header Validation + String contentType = servletRequest.getContentType(); + if (StringUtils.isEmpty(contentType)) { + errorMap.put(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_CONTENT_TYPE_INVALID); + } + if (artifactToUpload == null) { + throw new ActionException(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_MISSING_MANDATORY_PARAM + ARTIFACT_FILE); + } + try (InputStream artifactInputStream = artifactToUpload.getDataHandler().getInputStream()) { + payload = FileUtils.toByteArray(artifactInputStream); + } catch (IOException exception) { + LOGGER.error(ACTION_ARTIFACT_READ_FILE_ERROR, exception); + throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ARTIFACT_READ_FILE_ERROR); + } + //Validate Artifact size + if (payload != null && payload.length > MAX_ACTION_ARTIFACT_SIZE) { + throw new ActionException(ACTION_ARTIFACT_TOO_BIG_ERROR_CODE, ACTION_ARTIFACT_TOO_BIG_ERROR); + } + //Validate Checksum + if (StringUtils.isEmpty(checksum) || !checksum.equalsIgnoreCase(calculateCheckSum(payload))) { + errorMap.put(ACTION_ARTIFACT_CHECKSUM_ERROR_CODE, ACTION_REQUEST_ARTIFACT_CHECKSUM_ERROR); + } + //Validate artifact protection values + if (StringUtils.isEmpty(artifactProtection)) { + artifactProtection = ActionArtifactProtection.readWrite.name(); + } + if (!artifactProtection.equals(ActionArtifactProtection.readOnly.name()) && !artifactProtection + .equals(ActionArtifactProtection.readWrite.name())) { + errorMap.put(ACTION_ARTIFACT_INVALID_PROTECTION_CODE, ACTION_REQUEST_ARTIFACT_INVALID_PROTECTION_VALUE); + } + ActionArtifact uploadedArtifact = new ActionArtifact(); + if (errorMap.isEmpty()) { + String user = servletRequest.getRemoteUser(); + ActionArtifact upload = new ActionArtifact(); + upload.setArtifactName(artifactName); + upload.setArtifactLabel(artifactLabel); + upload.setArtifactDescription(artifactDescription); + upload.setArtifact(payload); + upload.setArtifactCategory(artifactCategory); + upload.setArtifactProtection(artifactProtection); + uploadedArtifact = actionManager.uploadArtifact(upload, actionInvariantUUID, user); + } else { + checkAndThrowError(errorMap); + } + return Response.ok(uploadedArtifact).build(); } - return Response.ok().build(); - } - @Override - public Response updateArtifact(String actionInvariantUUID, String artifactUUID, - String artifactName, String artifactLabel, String artifactCategory, - String artifactDescription, String artifactProtection, - String checksum, Attachment artifactToUpdate, - HttpServletRequest servletRequest) { - Response response = null; - LOGGER.debug(" entering updateArtifact with actionInvariantUuId= " + actionInvariantUUID + - " and artifactUUID= " + artifactUUID + " and artifactName= " + artifactName + - " and artifactLabel= " + artifactLabel + " and artifactCategory= " + artifactCategory + - " and artifactDescription= " + artifactDescription + " and artifactProtection= " + - artifactProtection + " and checksum= " + checksum); - try { - initializeRequestMDC(servletRequest, actionInvariantUUID, ActionRequest.UPDATE_ARTIFACT); - response = - updateArtifactInternal(actionInvariantUUID, artifactUUID, artifactName, artifactLabel, - artifactCategory, artifactDescription, artifactProtection, checksum, artifactToUpdate, - servletRequest); - actionLogPostProcessor(COMPLETE, true); - } catch (ActionException exception) { - actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); - LOGGER.error(MDC.get(ERROR_DESCRIPTION)); - throw exception; - } catch (Exception exception) { - actionLogPostProcessor(ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, - ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - LOGGER.error(exception.getMessage()); - throw exception; + @Override + public Response downloadArtifact(String actionUUID, String artifactUUID, HttpServletRequest servletRequest) { + Response response = null; + try { + initializeRequestMDC(servletRequest, "", ActionRequest.DOWNLOAD_ARTIFACT); + LOGGER.debug(" entering downloadArtifact with actionUUID= " + actionUUID + " and artifactUUID= " + artifactUUID); + response = downloadArtifactInternal(actionUUID, artifactUUID, servletRequest); + actionLogPostProcessor(COMPLETE, true); + } catch (ActionException exception) { + actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); + LOGGER.error(MDC.get(ERROR_DESCRIPTION)); + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + LOGGER.error(exception.getMessage()); + throw exception; + } + LOGGER.debug(" exit downloadArtifact with actionUUID= " + actionUUID + " and artifactUUID= " + artifactUUID); + return response; } - LOGGER.debug(" exit updateArtifact with actionInvariantUuId= " + actionInvariantUUID + - " and artifactUUID= " + artifactUUID + " and artifactName= " + artifactName + - " and artifactLabel= " + artifactLabel + " and artifactCategory= " + artifactCategory + - " and artifactDescription= " + artifactDescription + " and artifactProtection= " + - artifactProtection + " and checksum= " + checksum); - return response; - } - - private Response updateArtifactInternal(String actionInvariantUUID, String artifactUUID, - String artifactName, String artifactLabel, - String artifactCategory, String artifactDescription, - String artifactProtection, String checksum, - Attachment artifactToUpdate, - HttpServletRequest servletRequest) { - byte[] payload = null; - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - - //Content-Type Header Validation - String contentType = servletRequest.getContentType(); - if (StringUtils.isEmpty(contentType)) { - errorMap.put(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_CONTENT_TYPE_INVALID); + private Response downloadArtifactInternal(String actionUUID, String artifactUUID, HttpServletRequest servletRequest) { + Response response; + ActionArtifact actionartifact = null; + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + Map<String, String> queryParamErrors = validateQueryParam(actionUUID); + errorMap.putAll(queryParamErrors); + queryParamErrors = validateQueryParam(artifactUUID); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + actionartifact = actionManager.downloadArtifact(actionUUID, artifactUUID); + } else { + checkAndThrowError(errorMap); + } + response = createArtifactDownloadResponse(actionartifact); + return response; } - if (artifactToUpdate != null) { - - try (InputStream artifactInputStream = artifactToUpdate.getDataHandler().getInputStream()) { - payload = FileUtils.toByteArray(artifactInputStream); - } catch (IOException exception) { - LOGGER.error(ACTION_ARTIFACT_READ_FILE_ERROR, exception); - throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ARTIFACT_READ_FILE_ERROR); - } - - //Validate Artifact size - if (payload != null && payload.length > MAX_ACTION_ARTIFACT_SIZE) { - throw new ActionException(ACTION_ARTIFACT_TOO_BIG_ERROR_CODE, - ACTION_ARTIFACT_TOO_BIG_ERROR); - } - - //Validate Checksum - if (StringUtils.isEmpty(checksum) || !checksum.equalsIgnoreCase(calculateCheckSum(payload))) { - errorMap.put(ACTION_ARTIFACT_CHECKSUM_ERROR_CODE, ACTION_REQUEST_ARTIFACT_CHECKSUM_ERROR); - } + @Override + public Response deleteArtifact(String actionInvariantUUID, String artifactUUID, HttpServletRequest servletRequest) { + Response response = null; + try { + initializeRequestMDC(servletRequest, actionInvariantUUID, ActionRequest.DELETE_ARTIFACT); + LOGGER.debug(" entering deleteArtifact with actionInvariantUuId= " + actionInvariantUUID + " and artifactUUID= " + artifactUUID); + response = deleteArtifactInternal(actionInvariantUUID, artifactUUID, servletRequest); + LOGGER.debug(" exit deleteArtifact with actionInvariantUuId= " + actionInvariantUUID + " and artifactUUID= " + artifactUUID); + actionLogPostProcessor(COMPLETE, true); + } catch (ActionException exception) { + actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); + LOGGER.error(MDC.get(ERROR_DESCRIPTION)); + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + LOGGER.error(exception.getMessage()); + throw exception; + } + return response; } - if (artifactProtection != null && (artifactProtection.isEmpty() || - (!artifactProtection.equals(ActionArtifactProtection.readOnly.name()) && - !artifactProtection.equals(ActionArtifactProtection.readWrite.name())))) { - errorMap.put(ACTION_ARTIFACT_INVALID_PROTECTION_CODE, - ACTION_REQUEST_ARTIFACT_INVALID_PROTECTION_VALUE); + private Response deleteArtifactInternal(String actionInvariantUUID, String artifactUUID, HttpServletRequest servletRequest) { + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + Map<String, String> queryParamErrors = validateQueryParam(actionInvariantUUID); + errorMap.putAll(queryParamErrors); + queryParamErrors = validateQueryParam(artifactUUID); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + actionManager.deleteArtifact(actionInvariantUUID, artifactUUID, servletRequest.getRemoteUser()); + } else { + checkAndThrowError(errorMap); + } + return Response.ok().build(); } - ActionArtifact updateArtifact = new ActionArtifact(); - if (errorMap.isEmpty()) { - String user = servletRequest.getRemoteUser(); - ActionArtifact update = new ActionArtifact(); - update.setArtifactUuId(artifactUUID); - update.setArtifactName(artifactName); - update.setArtifactLabel(artifactLabel); - update.setArtifactDescription(artifactDescription); - update.setArtifact(payload); - update.setArtifactCategory(artifactCategory); - update.setArtifactProtection(artifactProtection); - actionManager.updateArtifact(update, actionInvariantUUID, user); - } else { - checkAndThrowError(errorMap); + @Override + public Response updateArtifact(String actionInvariantUUID, String artifactUUID, String artifactName, String artifactLabel, + String artifactCategory, String artifactDescription, String artifactProtection, String checksum, + Attachment artifactToUpdate, HttpServletRequest servletRequest) { + Response response = null; + LOGGER.debug( + " entering updateArtifact with actionInvariantUuId= " + actionInvariantUUID + " and artifactUUID= " + artifactUUID + " and artifactName= " + + artifactName + " and artifactLabel= " + artifactLabel + " and artifactCategory= " + artifactCategory + " and artifactDescription= " + + artifactDescription + " and artifactProtection= " + artifactProtection + " and checksum= " + checksum); + try { + initializeRequestMDC(servletRequest, actionInvariantUUID, ActionRequest.UPDATE_ARTIFACT); + response = updateArtifactInternal(actionInvariantUUID, artifactUUID, artifactName, artifactLabel, artifactCategory, artifactDescription, + artifactProtection, checksum, artifactToUpdate, servletRequest); + actionLogPostProcessor(COMPLETE, true); + } catch (ActionException exception) { + actionLogPostProcessor(ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); + LOGGER.error(MDC.get(ERROR_DESCRIPTION)); + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + LOGGER.error(exception.getMessage()); + throw exception; + } + LOGGER.debug( + " exit updateArtifact with actionInvariantUuId= " + actionInvariantUUID + " and artifactUUID= " + artifactUUID + " and artifactName= " + + artifactName + " and artifactLabel= " + artifactLabel + " and artifactCategory= " + artifactCategory + " and artifactDescription= " + + artifactDescription + " and artifactProtection= " + artifactProtection + " and checksum= " + checksum); + return response; } - return Response.ok().build(); - } - /** - * Get List of all actions - */ - private Response getAllActions(HttpServletRequest servletRequest) { - ListResponseWrapper responseList = null; - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - if (errorMap.isEmpty()) { - List<Action> actions = actionManager.getFilteredActions(FILTER_TYPE_NONE, null); - responseList = createResponse(actions); - } else { - checkAndThrowError(errorMap); + private Response updateArtifactInternal(String actionInvariantUUID, String artifactUUID, String artifactName, String artifactLabel, + String artifactCategory, String artifactDescription, String artifactProtection, String checksum, + Attachment artifactToUpdate, HttpServletRequest servletRequest) { + byte[] payload = null; + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + //Content-Type Header Validation + String contentType = servletRequest.getContentType(); + if (StringUtils.isEmpty(contentType)) { + errorMap.put(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_CONTENT_TYPE_INVALID); + } + if (artifactToUpdate != null) { + try (InputStream artifactInputStream = artifactToUpdate.getDataHandler().getInputStream()) { + payload = FileUtils.toByteArray(artifactInputStream); + } catch (IOException exception) { + LOGGER.error(ACTION_ARTIFACT_READ_FILE_ERROR, exception); + throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ARTIFACT_READ_FILE_ERROR); + } + //Validate Artifact size + if (payload != null && payload.length > MAX_ACTION_ARTIFACT_SIZE) { + throw new ActionException(ACTION_ARTIFACT_TOO_BIG_ERROR_CODE, ACTION_ARTIFACT_TOO_BIG_ERROR); + } + //Validate Checksum + if (StringUtils.isEmpty(checksum) || !checksum.equalsIgnoreCase(calculateCheckSum(payload))) { + errorMap.put(ACTION_ARTIFACT_CHECKSUM_ERROR_CODE, ACTION_REQUEST_ARTIFACT_CHECKSUM_ERROR); + } + } + if (artifactProtection != null && (artifactProtection.isEmpty() || (!artifactProtection.equals(ActionArtifactProtection.readOnly.name()) + && !artifactProtection.equals(ActionArtifactProtection.readWrite.name())))) { + errorMap.put(ACTION_ARTIFACT_INVALID_PROTECTION_CODE, ACTION_REQUEST_ARTIFACT_INVALID_PROTECTION_VALUE); + } + ActionArtifact updateArtifact = new ActionArtifact(); + if (errorMap.isEmpty()) { + String user = servletRequest.getRemoteUser(); + ActionArtifact update = new ActionArtifact(); + update.setArtifactUuId(artifactUUID); + update.setArtifactName(artifactName); + update.setArtifactLabel(artifactLabel); + update.setArtifactDescription(artifactDescription); + update.setArtifact(payload); + update.setArtifactCategory(artifactCategory); + update.setArtifactProtection(artifactProtection); + actionManager.updateArtifact(update, actionInvariantUUID, user); + } else { + checkAndThrowError(errorMap); + } + return Response.ok().build(); } - return Response.ok(responseList).build(); - } - - /** - * Get Actions by OPENECOMP component ID - */ - private Response getActionsByOpenEcompComponents(String componentID, - HttpServletRequest servletRequest) { - ListResponseWrapper responseList = null; - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - Map<String, String> queryParamErrors = validateQueryParam(componentID); - errorMap.putAll(queryParamErrors); - if (errorMap.isEmpty()) { - List<Action> actions = - actionManager.getFilteredActions(FILTER_TYPE_OPEN_ECOMP_COMPONENT, componentID); - responseList = createResponse(actions); - } else { - checkAndThrowError(errorMap); + /** + * Get List of all actions + */ + private Response getAllActions(HttpServletRequest servletRequest) { + ListResponseWrapper responseList = null; + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + if (errorMap.isEmpty()) { + List<Action> actions = actionManager.getFilteredActions(FILTER_TYPE_NONE, null); + responseList = createResponse(actions); + } else { + checkAndThrowError(errorMap); + } + return Response.ok(responseList).build(); } - return Response.ok(responseList).build(); - } - /** - * Get Actions by Model ID - */ - private Response getActionsByModel(String modelId, HttpServletRequest servletRequest) { - ListResponseWrapper responseList = null; - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - Map<String, String> queryParamErrors = validateQueryParam(modelId); - errorMap.putAll(queryParamErrors); - if (errorMap.isEmpty()) { - List<Action> actions = actionManager.getFilteredActions(FILTER_TYPE_MODEL, modelId); - responseList = createResponse(actions); - } else { - checkAndThrowError(errorMap); + /** + * Get Actions by OPENECOMP component ID + */ + private Response getActionsByOpenEcompComponents(String componentID, HttpServletRequest servletRequest) { + ListResponseWrapper responseList = null; + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + Map<String, String> queryParamErrors = validateQueryParam(componentID); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + List<Action> actions = actionManager.getFilteredActions(FILTER_TYPE_OPEN_ECOMP_COMPONENT, componentID); + responseList = createResponse(actions); + } else { + checkAndThrowError(errorMap); + } + return Response.ok(responseList).build(); } - return Response.ok(responseList).build(); - } - /** - * Get all actions with given action name - */ - private Response getActionsByName(String name, HttpServletRequest servletRequest) { - ListResponseWrapper responseList = null; - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - Map<String, String> queryParamErrors = validateQueryParam(name); - errorMap.putAll(queryParamErrors); - if (errorMap.isEmpty()) { - List<Action> actions = actionManager.getFilteredActions(FILTER_TYPE_NAME, name); - responseList = createResponse(actions); - } else { - checkAndThrowError(errorMap); + /** + * Get Actions by Model ID + */ + private Response getActionsByModel(String modelId, HttpServletRequest servletRequest) { + ListResponseWrapper responseList = null; + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + Map<String, String> queryParamErrors = validateQueryParam(modelId); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + List<Action> actions = actionManager.getFilteredActions(FILTER_TYPE_MODEL, modelId); + responseList = createResponse(actions); + } else { + checkAndThrowError(errorMap); + } + return Response.ok(responseList).build(); } - return Response.ok(responseList).build(); - } - /** - * Get an action with given ActionUUID - */ - private Response getActionsByUniqueID(String actionUUID, HttpServletRequest servletRequest, - String actionInvariantUUID) { - LOGGER.debug( - " entering getActionByUUID with invariantID= " + actionInvariantUUID + " and actionUUID= " + - actionUUID); - Map<String, Object> responseDTO = new LinkedHashMap<>(); - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - Map<String, String> queryParamErrors = validateQueryParam(actionUUID); - errorMap.putAll(queryParamErrors); - if (errorMap.isEmpty()) { - Action action = actionManager.getActionsByActionUuId(actionUUID); - if (action.getActionInvariantUuId() != null && - action.getActionInvariantUuId().equalsIgnoreCase(actionInvariantUUID)) { - responseDTO = JsonUtil.json2Object(action.getData(), LinkedHashMap.class); - responseDTO.put(STATUS, action.getStatus().name()); - responseDTO.put(TIMESTAMP, getUtcDateStringFromTimestamp(action.getTimestamp())); - responseDTO.put(UPDATED_BY, action.getUser()); - } else { - throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST); - } - } else { - checkAndThrowError(errorMap); + /** + * Get all actions with given action name + */ + private Response getActionsByName(String name, HttpServletRequest servletRequest) { + ListResponseWrapper responseList = null; + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + Map<String, String> queryParamErrors = validateQueryParam(name); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + List<Action> actions = actionManager.getFilteredActions(FILTER_TYPE_NAME, name); + responseList = createResponse(actions); + } else { + checkAndThrowError(errorMap); + } + return Response.ok(responseList).build(); } - LOGGER.debug( - " exit getActionByUUID with invariantID= " + actionInvariantUUID + " and actionUUID= " + - actionUUID); - return Response.ok(responseDTO).build(); - } - /** - * Get all actions with given Vendor Name - */ - private Response getActionsByVendor(String vendor, HttpServletRequest servletRequest) { - //Validate request syntax before passing to the manager - ListResponseWrapper responseList = null; - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - Map<String, String> queryParamErrors = validateQueryParam(vendor); - errorMap.putAll(queryParamErrors); - if (errorMap.isEmpty()) { - List<Action> actions = actionManager.getFilteredActions(FILTER_TYPE_VENDOR, vendor); - responseList = createResponse(actions); - } else { - checkAndThrowError(errorMap); + /** + * Get an action with given ActionUUID + */ + private Response getActionsByUniqueID(String actionUUID, HttpServletRequest servletRequest, String actionInvariantUUID) { + LOGGER.debug(" entering getActionByUUID with invariantID= " + actionInvariantUUID + " and actionUUID= " + actionUUID); + Map<String, Object> responseDTO = new LinkedHashMap<>(); + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + Map<String, String> queryParamErrors = validateQueryParam(actionUUID); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + Action action = actionManager.getActionsByActionUuId(actionUUID); + if (action.getActionInvariantUuId() != null && action.getActionInvariantUuId().equalsIgnoreCase(actionInvariantUUID)) { + responseDTO = JsonUtil.json2Object(action.getData(), LinkedHashMap.class); + responseDTO.put(STATUS, action.getStatus().name()); + responseDTO.put(TIMESTAMP, getUtcDateStringFromTimestamp(action.getTimestamp())); + responseDTO.put(UPDATED_BY, action.getUser()); + } else { + throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST); + } + } else { + checkAndThrowError(errorMap); + } + LOGGER.debug(" exit getActionByUUID with invariantID= " + actionInvariantUUID + " and actionUUID= " + actionUUID); + return Response.ok(responseDTO).build(); } - return Response.ok(responseList).build(); - } - /** - * Get all actions with given Category Name - */ - private Response getActionsByCategory(String category, HttpServletRequest servletRequest) { - //Validate request syntax before passing to the manager - ListResponseWrapper responseList = null; - Map<String, String> errorMap = validateRequestHeaders(servletRequest); - Map<String, String> queryParamErrors = validateQueryParam(category); - errorMap.putAll(queryParamErrors); - if (errorMap.isEmpty()) { - List<Action> actions = actionManager.getFilteredActions(FILTER_TYPE_CATEGORY, category); - responseList = createResponse(actions); - } else { - checkAndThrowError(errorMap); + /** + * Get all actions with given Vendor Name + */ + private Response getActionsByVendor(String vendor, HttpServletRequest servletRequest) { + //Validate request syntax before passing to the manager + ListResponseWrapper responseList = null; + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + Map<String, String> queryParamErrors = validateQueryParam(vendor); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + List<Action> actions = actionManager.getFilteredActions(FILTER_TYPE_VENDOR, vendor); + responseList = createResponse(actions); + } else { + checkAndThrowError(errorMap); + } + return Response.ok(responseList).build(); } - return Response.ok(responseList).build(); - } - /** - * Validates mandatory headers in the request - * - * @param servletRequest Servlet Request object - * @return Map of error codes and description found in the request headers - */ - private Map<String, String> validateRequestHeaders(HttpServletRequest servletRequest) { - Map<String, String> errorMap = new LinkedHashMap<>(); - //Syntactic generic request parameter validations - String openEcompRequestId = servletRequest.getHeader(X_OPEN_ECOMP_REQUEST_ID_HEADER_PARAM); - if (StringUtils.isEmpty(openEcompRequestId)) { - errorMap.put(ACTION_INVALID_REQUEST_ID_CODE, ACTION_REQUEST_OPEN_ECOMP_REQUEST_ID_INVALID); + /** + * Get all actions with given Category Name + */ + private Response getActionsByCategory(String category, HttpServletRequest servletRequest) { + //Validate request syntax before passing to the manager + ListResponseWrapper responseList = null; + Map<String, String> errorMap = validateRequestHeaders(servletRequest); + Map<String, String> queryParamErrors = validateQueryParam(category); + errorMap.putAll(queryParamErrors); + if (errorMap.isEmpty()) { + List<Action> actions = actionManager.getFilteredActions(FILTER_TYPE_CATEGORY, category); + responseList = createResponse(actions); + } else { + checkAndThrowError(errorMap); + } + return Response.ok(responseList).build(); } - String opemnEcompInstanceId = servletRequest.getHeader(X_OPEN_ECOMP_INSTANCE_ID_HEADER_PARAM); - if (StringUtils.isEmpty(opemnEcompInstanceId)) { - errorMap.put(ACTION_INVALID_INSTANCE_ID_CODE, ACTION_REQUEST_OPEN_ECOMP_INSTANCE_ID_INVALID); + /** + * Validates mandatory headers in the request + * + * @param servletRequest Servlet Request object + * @return Map of error codes and description found in the request headers + */ + private Map<String, String> validateRequestHeaders(HttpServletRequest servletRequest) { + Map<String, String> errorMap = new LinkedHashMap<>(); + //Syntactic generic request parameter validations + String openEcompRequestId = servletRequest.getHeader(X_OPEN_ECOMP_REQUEST_ID_HEADER_PARAM); + if (StringUtils.isEmpty(openEcompRequestId)) { + errorMap.put(ACTION_INVALID_REQUEST_ID_CODE, ACTION_REQUEST_OPEN_ECOMP_REQUEST_ID_INVALID); + } + String opemnEcompInstanceId = servletRequest.getHeader(X_OPEN_ECOMP_INSTANCE_ID_HEADER_PARAM); + if (StringUtils.isEmpty(opemnEcompInstanceId)) { + errorMap.put(ACTION_INVALID_INSTANCE_ID_CODE, ACTION_REQUEST_OPEN_ECOMP_INSTANCE_ID_INVALID); + } + return errorMap; } - return errorMap; - } - /** - * Validates query parameter in the request - * - * @param queryParam Query Parameter to be validated - * @return Map of error codes and description found in the query parameter - */ - private Map<String, String> validateQueryParam(String queryParam) { - Map<String, String> queryParamErrors = new LinkedHashMap<>(); - if (StringUtils.isEmpty(queryParam)) { - queryParamErrors - .put(ACTION_INVALID_PARAM_CODE, ACTION_REQUEST_MISSING_MANDATORY_PARAM + queryParam); + /** + * Validates query parameter in the request + * + * @param queryParam Query Parameter to be validated + * @return Map of error codes and description found in the query parameter + */ + private Map<String, String> validateQueryParam(String queryParam) { + Map<String, String> queryParamErrors = new LinkedHashMap<>(); + if (StringUtils.isEmpty(queryParam)) { + queryParamErrors.put(ACTION_INVALID_PARAM_CODE, ACTION_REQUEST_MISSING_MANDATORY_PARAM + queryParam); + } + return queryParamErrors; } - return queryParamErrors; - } - /** - * Validate request body based on request type - * - * @param requestJSON Raw request json body as string - * @return Map of error codes and description found in the request body - */ - private Map<String, String> validateRequestBody(String requestType, String requestJSON) { - Map<String, String> requestBodyErrorMap = new LinkedHashMap<>(); - if (StringUtils.isEmpty(requestJSON) || requestJSON.equals(REQUEST_EMPTY_BODY)) { - requestBodyErrorMap.put(ACTION_INVALID_REQUEST_BODY_CODE, ACTION_REQUEST_BODY_EMPTY); - } else { - if(requestType == ActionConstants.REQUEST_TYPE_CREATE_ACTION - || requestType == ActionConstants.REQUEST_TYPE_UPDATE_ACTION){ - //Semantic request specific validations - Action action = JsonUtil.json2Object(requestJSON, Action.class); - if(StringUtils.isEmpty(action.getName())){ - setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_PARAM_NAME, - requestBodyErrorMap); + /** + * Validate request body based on request type + * + * @param requestJSON Raw request json body as string + * @return Map of error codes and description found in the request body + */ + private Map<String, String> validateRequestBody(String requestType, String requestJSON) { + Map<String, String> requestBodyErrorMap = new LinkedHashMap<>(); + if (StringUtils.isEmpty(requestJSON) || requestJSON.equals(REQUEST_EMPTY_BODY)) { + requestBodyErrorMap.put(ACTION_INVALID_REQUEST_BODY_CODE, ACTION_REQUEST_BODY_EMPTY); } else { - //Added check for action names not allowing whitespaces - if (action.getName().matches(whitespaceRegex)){ - requestBodyErrorMap.put(ACTION_ARTIFACT_INVALID_NAME_CODE, ACTION_REQUEST_INVALID_NAME); - } + if (requestType == ActionConstants.REQUEST_TYPE_CREATE_ACTION || requestType == ActionConstants.REQUEST_TYPE_UPDATE_ACTION) { + //Semantic request specific validations + Action action = JsonUtil.json2Object(requestJSON, Action.class); + if (StringUtils.isEmpty(action.getName())) { + setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_PARAM_NAME, requestBodyErrorMap); + } else { + //Added check for action names not allowing whitespaces + if (action.getName().matches(whitespaceRegex)) { + requestBodyErrorMap.put(ACTION_ARTIFACT_INVALID_NAME_CODE, ACTION_REQUEST_INVALID_NAME); + } + } + if (action.getSupportedModels() != null && !isIDPresentInMap(action.getSupportedModels(), SUPPORTED_MODELS_VERSION_ID)) { + setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_PARAM_SUPPORTED_MODELS, requestBodyErrorMap); + } + if (action.getSupportedComponents() != null && !isIDPresentInMap(action.getSupportedComponents(), SUPPORTED_COMPONENTS_ID)) { + setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_PARAM_SUPPORTED_COMPONENTS, requestBodyErrorMap); + } + if (action.getArtifacts() != null) { + setErrorValue(ACTION_UPDATE_NOT_ALLOWED_CODE, ACTION_REQUEST_ARTIFACT_OPERATION_ALLOWED, requestBodyErrorMap); + } + } } + return requestBodyErrorMap; + } - if(action.getSupportedModels() != null && !isIDPresentInMap(action.getSupportedModels(), - SUPPORTED_MODELS_VERSION_ID)){ - setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, - ACTION_REQUEST_PARAM_SUPPORTED_MODELS, requestBodyErrorMap); - } - if(action.getSupportedComponents() != null && !isIDPresentInMap(action - .getSupportedComponents(), SUPPORTED_COMPONENTS_ID)){ - setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, - ACTION_REQUEST_PARAM_SUPPORTED_COMPONENTS, requestBodyErrorMap); - } - if(action.getArtifacts() != null){ - setErrorValue(ACTION_UPDATE_NOT_ALLOWED_CODE, - ACTION_REQUEST_ARTIFACT_OPERATION_ALLOWED, requestBodyErrorMap); + /** + * Populates Given Error Map with Given Error Code and Error MEssage + */ + private void setErrorValue(String key, String message, Map<String, String> errorMap) { + String errorMessage = errorMap.get(key); + if (errorMessage != null) { + message = errorMessage + ", " + message; + } else { + if (key == ACTION_REQUEST_INVALID_GENERIC_CODE) { + message = ACTION_REQUEST_MISSING_MANDATORY_PARAM + message; + } } - } - + errorMap.put(key, message); } - return requestBodyErrorMap; - } - /** - * Populates Given Error Map with Given Error Code and Error MEssage - */ - private void setErrorValue(String key, String message, Map<String, String> errorMap) { - String errorMessage = errorMap.get(key); - if (errorMessage != null) { - message = errorMessage + ", " + message; - } else { - if(key == ACTION_REQUEST_INVALID_GENERIC_CODE) - message = ACTION_REQUEST_MISSING_MANDATORY_PARAM + message; + /** + * Returns true if given key exists in List of HashMap + */ + private boolean isIDPresentInMap(List<Map<String, String>> map, String idName) { + if (map != null && !map.isEmpty()) { + for (Map<String, String> entry : map) { + if (StringUtils.isEmpty(entry.get(idName))) { + return false; + } + } + } + return true; } - errorMap.put(key, message); - } - /** - * Returns true if given key exists in List of HashMap - */ - private boolean isIDPresentInMap(List<Map<String, String>> map, String idName) { - if (map != null && !map.isEmpty()) { - for (Map<String, String> entry : map) { - if (StringUtils.isEmpty(entry.get(idName))) { - return false; + /** + * @throws ActionException if given ErrorMap is not empty. All error messages at given time are thrown in one single exception + */ + private void checkAndThrowError(Map<String, String> errorMap) { + if (errorMap.size() > 1) { + //Multiple errors detected .. Send the response with a common error code for multiple errors + throw new ActionException(ACTION_REQUEST_INVALID_GENERIC_CODE, StringUtils.join(errorMap.values(), ", ")); + } else if (errorMap.size() == 1) { + String svcPolicyExceptionCode = errorMap.entrySet().iterator().next().getKey(); + throw new ActionException(svcPolicyExceptionCode, errorMap.get(svcPolicyExceptionCode)); } - } } - return true; - } - /** - * @throws ActionException if given ErrorMap is not empty. All error messages at given time are - * thrown in one single exception - */ - private void checkAndThrowError(Map<String, String> errorMap) { - if (errorMap.size() > 1) { - //Multiple errors detected .. Send the response with a common error code for multiple errors - throw new ActionException(ACTION_REQUEST_INVALID_GENERIC_CODE, - StringUtils.join(errorMap.values(), ", ")); - } else if (errorMap.size() == 1) { - String svcPolicyExceptionCode = errorMap.entrySet().iterator().next().getKey(); - throw new ActionException(svcPolicyExceptionCode, - errorMap.get(svcPolicyExceptionCode)); + /** + * Populates ActionResponseDto based on given Action + */ + private ActionResponseDto createResponseDTO(Action action) { + String data = action.getData(); + ActionResponseDto responseDTO = JsonUtil.json2Object(data, ActionResponseDto.class); + responseDTO.setStatus(action.getStatus().name()); + responseDTO.setTimestamp(getUtcDateStringFromTimestamp(action.getTimestamp())); + //if(!action.getUser().equals(DELETE_ACTION_USER)) + responseDTO.setUpdatedBy(action.getUser()); + return responseDTO; } - } - /** - * Populates ActionResponseDto based on given Action - */ - private ActionResponseDto createResponseDTO(Action action) { - String data = action.getData(); - ActionResponseDto responseDTO = JsonUtil.json2Object(data, ActionResponseDto.class); - responseDTO.setStatus(action.getStatus().name()); - responseDTO.setTimestamp(getUtcDateStringFromTimestamp(action.getTimestamp())); - //if(!action.getUser().equals(DELETE_ACTION_USER)) - responseDTO.setUpdatedBy(action.getUser()); - return responseDTO; - } - - /** - * Creates response based on given list of actions - */ - private ListResponseWrapper createResponse(List<Action> actions) { - ListResponseWrapper responseList = new ListResponseWrapper(); - for (Action action : actions) { - ActionResponseDto responseDTO = createResponseDTO(action); - responseList.add(responseDTO); + /** + * Creates response based on given list of actions + */ + private ListResponseWrapper createResponse(List<Action> actions) { + ListResponseWrapper responseList = new ListResponseWrapper(); + for (Action action : actions) { + ActionResponseDto responseDTO = createResponseDTO(action); + responseList.add(responseDTO); + } + return responseList; } - return responseList; - } - - private Response createArtifactDownloadResponse(ActionArtifact actionartifact) { - if (actionartifact != null && actionartifact.getArtifact() != null) { - byte[] artifactsBytes = actionartifact.getArtifact(); - File artifactFile = new File(actionartifact.getArtifactName()); - try (FileOutputStream fos = new FileOutputStream(artifactFile)) { - fos.write(artifactsBytes); - } catch (IOException exception) { - LOGGER.error(ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG, exception); - throw new ActionException(ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE, - ActionErrorConstants.ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - } - Response.ResponseBuilder responseBuilder = Response.ok(artifactFile); - responseBuilder.header("Content-Disposition", - "attachment; filename=" + actionartifact.getArtifactName()); - responseBuilder.header("Content-MD5", CalcMD5CheckSum(artifactsBytes)); - responseBuilder.header("Content-Length", artifactFile.length()); - return responseBuilder.build(); - } else { - throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE, - ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST); + private Response createArtifactDownloadResponse(ActionArtifact actionartifact) { + if (actionartifact != null && actionartifact.getArtifact() != null) { + byte[] artifactsBytes = actionartifact.getArtifact(); + File artifactFile = new File(actionartifact.getArtifactName()); + try (FileOutputStream fos = new FileOutputStream(artifactFile)) { + fos.write(artifactsBytes); + } catch (IOException exception) { + LOGGER.error(ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG, exception); + throw new ActionException(ActionErrorConstants.ACTION_INTERNAL_SERVER_ERR_CODE, + ActionErrorConstants.ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + } + Response.ResponseBuilder responseBuilder = Response.ok(artifactFile); + responseBuilder.header("Content-Disposition", "attachment; filename=" + actionartifact.getArtifactName()); + responseBuilder.header("Content-MD5", CalcMD5CheckSum(artifactsBytes)); + responseBuilder.header("Content-Length", artifactFile.length()); + return responseBuilder.build(); + } else { + throw new ActionException(ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST_CODE, + ActionErrorConstants.ACTION_ARTIFACT_ENTITY_NOT_EXIST); + } } - } - - /** - * Initialize MDC for logging the current request - * - * @param actionInvariantId Action Invariant Id if available (null otherwise) - * @param servletRequest Request Contecxt object - * @param requestType Current action request (CRUD of Action, Artifact, Version operations) - */ - private void initializeRequestMDC(HttpServletRequest servletRequest, String actionInvariantId, - ActionRequest requestType) { - MDC.put(REQUEST_ID, servletRequest.getHeader(X_OPEN_ECOMP_REQUEST_ID_HEADER_PARAM)); - MDC.put(PARTNER_NAME, servletRequest.getRemoteUser()); - MDC.put(INSTANCE_UUID, MDC_ASDC_INSTANCE_UUID); - MDC.put(SERVICE_METRIC_BEGIN_TIMESTAMP, String.valueOf(System.currentTimeMillis())); - MDC.put(STATUS_CODE, COMPLETE.name()); - MDC.put(SERVICE_NAME, requestType.name()); - MDC.put(CLIENT_IP, MDC.get(REMOTE_HOST)); - MDC.put(SERVICE_INSTANCE_ID, actionInvariantId); - MDC.put(LOCAL_ADDR, MDC.get("ServerIPAddress")); - MDC.put(BE_FQDN, MDC.get("ServerFQDN")); - if (LOGGER.isDebugEnabled()) { - MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.DEBUG.name()); - } else if (LOGGER.isInfoEnabled()) { - MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.INFO.name()); - } else if (LOGGER.isWarnEnabled()) { - MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.WARN.name()); - } else if (LOGGER.isErrorEnabled()) { - MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.ERROR.name()); + /** + * Initialize MDC for logging the current request + * + * @param actionInvariantId Action Invariant Id if available (null otherwise) + * @param servletRequest Request Contecxt object + * @param requestType Current action request (CRUD of Action, Artifact, Version operations) + */ + private void initializeRequestMDC(HttpServletRequest servletRequest, String actionInvariantId, ActionRequest requestType) { + MDC.put(REQUEST_ID, servletRequest.getHeader(X_OPEN_ECOMP_REQUEST_ID_HEADER_PARAM)); + MDC.put(PARTNER_NAME, servletRequest.getRemoteUser()); + MDC.put(INSTANCE_UUID, MDC_ASDC_INSTANCE_UUID); + MDC.put(SERVICE_METRIC_BEGIN_TIMESTAMP, String.valueOf(System.currentTimeMillis())); + MDC.put(STATUS_CODE, COMPLETE.name()); + MDC.put(SERVICE_NAME, requestType.name()); + MDC.put(CLIENT_IP, MDC.get(REMOTE_HOST)); + MDC.put(SERVICE_INSTANCE_ID, actionInvariantId); + MDC.put(LOCAL_ADDR, MDC.get("ServerIPAddress")); + MDC.put(BE_FQDN, MDC.get("ServerFQDN")); + if (LOGGER.isDebugEnabled()) { + MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.DEBUG.name()); + } else if (LOGGER.isInfoEnabled()) { + MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.INFO.name()); + } else if (LOGGER.isWarnEnabled()) { + MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.WARN.name()); + } else if (LOGGER.isErrorEnabled()) { + MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.ERROR.name()); + } } - } - private String CalcMD5CheckSum(byte[] input) { - String checksum = null; - if (input != null) { - checksum = DigestUtils.md5Hex(input).toUpperCase(); - System.out.println("checksum : " + checksum); + private String CalcMD5CheckSum(byte[] input) { + String checksum = null; + if (input != null) { + checksum = DigestUtils.md5Hex(input).toUpperCase(); + System.out.println("checksum : " + checksum); + } + return checksum; } - return checksum; - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionResponseDto.java index 804473b008..dc0f33b3ba 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionResponseDto.java @@ -17,13 +17,10 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.action.types; - import java.util.HashMap; import java.util.List; -import lombok.Data; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionVersionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionVersionDto.java index 2925fe106b..30b4ba825b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionVersionDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ActionVersionDto.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.action.types; import lombok.Getter; @@ -28,5 +27,4 @@ import lombok.Setter; public class ActionVersionDto { String status; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ListResponseWrapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ListResponseWrapper.java index f60a5cafa4..24c19bf485 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ListResponseWrapper.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/src/main/java/org/openecomp/sdcrests/action/types/ListResponseWrapper.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.action.types; import java.util.ArrayList; @@ -27,8 +26,7 @@ import lombok.Setter; import org.openecomp.sdc.action.types.OpenEcompComponent; /** - * Defines DTO used for creating Response with list of {@link ActionResponseDto } or list of {@link - * openEcompComponent }. + * Defines DTO used for creating Response with list of {@link ActionResponseDto } or list of {@link openEcompComponent }. */ @Getter @Setter diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java index 1731688e06..5145b048aa 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/ApplicationConfiguration.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,29 +17,30 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.applicationconfig.rest; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import java.io.InputStream; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.openecomp.sdcrests.applicationconfiguration.types.ApplicationConfigDto; import org.openecomp.sdcrests.applicationconfiguration.types.ConfigurationDataDto; -import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.validation.annotation.Validated; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.InputStream; -import java.util.List; - @Path("/v1.0/application-configuration") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -47,23 +48,20 @@ import java.util.List; @Validated public interface ApplicationConfiguration { - @POST - @Path("/") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Operation(description = "Insert JSON schema into application config table") - Response insertToTable(@QueryParam("namespace") String namespace, @QueryParam("key") String key, - @Multipart("description") InputStream fileContainingSchema); - - - @GET - @Path("/{namespace}/{key}") - @Operation(description = "Get JSON schema by namespace and key", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ConfigurationDataDto.class)))) - Response getFromTable(@PathParam("namespace") String namespace, @PathParam("key") String key); - + @POST + @Path("/") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Operation(description = "Insert JSON schema into application config table") + Response insertToTable(@QueryParam("namespace") String namespace, @QueryParam("key") String key, + @Multipart("description") InputStream fileContainingSchema); - @GET - @Path("/{namespace}") - @Operation(description = "Get List of keys and descriptions by namespace", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApplicationConfigDto.class))))) - Response getListOfConfigurationByNamespaceFromTable(@PathParam("namespace") String namespace); + @GET + @Path("/{namespace}/{key}") + @Operation(description = "Get JSON schema by namespace and key", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ConfigurationDataDto.class)))) + Response getFromTable(@PathParam("namespace") String namespace, @PathParam("key") String key); + @GET + @Path("/{namespace}") + @Operation(description = "Get List of keys and descriptions by namespace", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApplicationConfigDto.class))))) + Response getListOfConfigurationByNamespaceFromTable(@PathParam("namespace") String namespace); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapApplicationConfigEntityToApplicationConfigDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapApplicationConfigEntityToApplicationConfigDto.java index 4ced6ba302..60fdecd714 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapApplicationConfigEntityToApplicationConfigDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapApplicationConfigEntityToApplicationConfigDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.applicationconfig.rest.mapping; import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity; @@ -27,11 +26,11 @@ import org.openecomp.sdcrests.mapping.MappingBase; /** * Created by Talio on 8/10/2016. */ -public class MapApplicationConfigEntityToApplicationConfigDto - extends MappingBase<ApplicationConfigEntity, ApplicationConfigDto> { - @Override - public void doMapping(ApplicationConfigEntity source, ApplicationConfigDto target) { - target.setKey(source.getKey()); - target.setValue(source.getValue()); - } +public class MapApplicationConfigEntityToApplicationConfigDto extends MappingBase<ApplicationConfigEntity, ApplicationConfigDto> { + + @Override + public void doMapping(ApplicationConfigEntity source, ApplicationConfigDto target) { + target.setKey(source.getKey()); + target.setValue(source.getValue()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapConfigurationDataToConfigurationDataDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapConfigurationDataToConfigurationDataDto.java index c86628d301..1730a21801 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapConfigurationDataToConfigurationDataDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/mapping/MapConfigurationDataToConfigurationDataDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.applicationconfig.rest.mapping; import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData; @@ -27,11 +26,11 @@ import org.openecomp.sdcrests.mapping.MappingBase; /** * Created by Talio on 8/9/2016. */ -public class MapConfigurationDataToConfigurationDataDto - extends MappingBase<ConfigurationData, ConfigurationDataDto> { - @Override - public void doMapping(ConfigurationData source, ConfigurationDataDto target) { - target.setValue(source.getValue()); - target.setTimeStamp(source.getTimeStamp()); - } +public class MapConfigurationDataToConfigurationDataDto extends MappingBase<ConfigurationData, ConfigurationDataDto> { + + @Override + public void doMapping(ConfigurationData source, ConfigurationDataDto target) { + target.setValue(source.getValue()); + target.setTimeStamp(source.getTimeStamp()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java index 349ec87276..2f6c8a8be6 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/src/main/java/org/openecomp/sdcrests/applicationconfig/rest/services/ApplicationConfigurationImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,9 +19,12 @@ * Modifications copyright (c) 2019 Nokia * ================================================================================ */ - package org.openecomp.sdcrests.applicationconfig.rest.services; +import java.io.InputStream; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfigEntity; import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData; import org.openecomp.core.utilities.file.FileUtils; @@ -36,55 +39,43 @@ 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.InputStream; -import java.util.Collection; - /** * Created by Talio on 8/8/2016. */ - @Named @Service("applicationConfiguration") @Scope(value = "prototype") public class ApplicationConfigurationImpl implements ApplicationConfiguration { - private final ApplicationConfigManager applicationConfigManager; - - @Autowired - public ApplicationConfigurationImpl(ApplicationConfigManager applicationConfigManager) { - this.applicationConfigManager = applicationConfigManager; - } + private final ApplicationConfigManager applicationConfigManager; - @Override - public Response insertToTable(String namespace, String key, InputStream fileContainingSchema) { - String value = new String(FileUtils.toByteArray(fileContainingSchema)); - applicationConfigManager.insertIntoTable(namespace, key, value); - return Response.ok().build(); - } + @Autowired + public ApplicationConfigurationImpl(ApplicationConfigManager applicationConfigManager) { + this.applicationConfigManager = applicationConfigManager; + } - @Override - public Response getFromTable(String namespace, String key) { - ConfigurationData value = applicationConfigManager.getFromTable(namespace, key); - ConfigurationDataDto valueDto = new MapConfigurationDataToConfigurationDataDto() - .applyMapping(value, ConfigurationDataDto.class); - return Response.ok(valueDto).build(); - } + @Override + public Response insertToTable(String namespace, String key, InputStream fileContainingSchema) { + String value = new String(FileUtils.toByteArray(fileContainingSchema)); + applicationConfigManager.insertIntoTable(namespace, key, value); + return Response.ok().build(); + } - @Override - public Response getListOfConfigurationByNamespaceFromTable(String namespace) { - Collection<ApplicationConfigEntity> applicationConfigEntities = - applicationConfigManager.getListOfConfigurationByNamespace(namespace); - GenericCollectionWrapper<ApplicationConfigDto> applicationConfigWrapper = - new GenericCollectionWrapper<>(); - MapApplicationConfigEntityToApplicationConfigDto mapper = - new MapApplicationConfigEntityToApplicationConfigDto(); + @Override + public Response getFromTable(String namespace, String key) { + ConfigurationData value = applicationConfigManager.getFromTable(namespace, key); + ConfigurationDataDto valueDto = new MapConfigurationDataToConfigurationDataDto().applyMapping(value, ConfigurationDataDto.class); + return Response.ok(valueDto).build(); + } - for (ApplicationConfigEntity applicationConfigEntity : applicationConfigEntities) { - applicationConfigWrapper - .add(mapper.applyMapping(applicationConfigEntity, ApplicationConfigDto.class)); + @Override + public Response getListOfConfigurationByNamespaceFromTable(String namespace) { + Collection<ApplicationConfigEntity> applicationConfigEntities = applicationConfigManager.getListOfConfigurationByNamespace(namespace); + GenericCollectionWrapper<ApplicationConfigDto> applicationConfigWrapper = new GenericCollectionWrapper<>(); + MapApplicationConfigEntityToApplicationConfigDto mapper = new MapApplicationConfigEntityToApplicationConfigDto(); + for (ApplicationConfigEntity applicationConfigEntity : applicationConfigEntities) { + applicationConfigWrapper.add(mapper.applyMapping(applicationConfigEntity, ApplicationConfigDto.class)); + } + return Response.ok(applicationConfigWrapper).build(); } - return Response.ok(applicationConfigWrapper).build(); - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ApplicationConfigDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ApplicationConfigDto.java index 63834a3983..d705d556aa 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ApplicationConfigDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ApplicationConfigDto.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.applicationconfiguration.types; import lombok.Getter; @@ -32,5 +31,4 @@ public class ApplicationConfigDto { private String key; private String value; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ConfigurationDataDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ConfigurationDataDto.java index 75aaf756d5..c6638680c4 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ConfigurationDataDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/src/main/java/org/openecomp/sdcrests/applicationconfiguration/types/ConfigurationDataDto.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.applicationconfiguration.types; import lombok.AllArgsConstructor; @@ -33,6 +32,7 @@ import lombok.Setter; @AllArgsConstructor @NoArgsConstructor public class ConfigurationDataDto { - private String value; - private long timeStamp; + + private String value; + private long timeStamp; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java index a6acfdba9c..0762325882 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/Conflicts.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,28 +17,31 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.conflict.rest; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdcrests.common.RestConstants; import org.openecomp.sdcrests.conflict.types.ConflictDto; import org.openecomp.sdcrests.conflict.types.ConflictResolutionDto; import org.openecomp.sdcrests.conflict.types.ItemVersionConflictDto; 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; - @Path("/v1.0/items/{itemId}/versions/{versionId}/conflicts") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -46,35 +49,26 @@ import javax.ws.rs.core.Response; @Validated public interface Conflicts { - @GET - @Path("/") - @Operation(description = "item version conflicts", - summary = "Item version private copy conflicts against its public copy", - responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ItemVersionConflictDto.class)))) - Response getConflict(@Parameter(description = "Item Id") @PathParam("itemId") String itemId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "item version conflicts", summary = "Item version private copy conflicts against its public copy", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ItemVersionConflictDto.class)))) + Response getConflict(@Parameter(description = "Item Id") @PathParam("itemId") String itemId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{conflictId}") - @Operation(description = "Gets item version conflict", - summary = "Gets an item version private copy conflict against its public copy", - responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ConflictDto.class)))) - Response getConflict(@Parameter(description = "Item Id") @PathParam("itemId") String itemId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Version Id") @PathParam("conflictId") String conflictId, - @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{conflictId}") + @Operation(description = "Gets item version conflict", summary = "Gets an item version private copy conflict against its public copy", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ConflictDto.class)))) + Response getConflict(@Parameter(description = "Item Id") @PathParam("itemId") String itemId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Version Id") @PathParam("conflictId") String conflictId, + @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{conflictId}") - @Operation(description = "Resolves item version conflict", - summary = "Resolves an item version private copy conflict against its public copy") - Response resolveConflict(ConflictResolutionDto conflictResolution, - @Parameter(description = "Item Id") @PathParam("itemId") String itemId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Version Id") @PathParam("conflictId") String conflictId, - @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{conflictId}") + @Operation(description = "Resolves item version conflict", summary = "Resolves an item version private copy conflict against its public copy") + Response resolveConflict(ConflictResolutionDto conflictResolution, @Parameter(description = "Item Id") @PathParam("itemId") String itemId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Version Id") @PathParam("conflictId") String conflictId, + @NotNull(message = RestConstants.USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java index 274a0cc674..7213fafa0b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictInfoToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.conflict.rest.mapping; import org.openecomp.conflicts.types.ConflictInfo; @@ -25,10 +24,11 @@ import org.openecomp.sdcrests.conflict.types.ConflictInfoDto; import org.openecomp.sdcrests.mapping.MappingBase; public class MapConflictInfoToDto extends MappingBase<ConflictInfo, ConflictInfoDto> { - @Override - public void doMapping(ConflictInfo source, ConflictInfoDto target) { - target.setId(source.getId()); - target.setType(source.getType()); - target.setName(source.getName()); - } + + @Override + public void doMapping(ConflictInfo source, ConflictInfoDto target) { + target.setId(source.getId()); + target.setType(source.getType()); + target.setName(source.getName()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java index 1a1f3296fa..a1615bfccf 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapConflictToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,108 +17,119 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.conflict.rest.mapping; +import java.util.AbstractMap; +import java.util.HashMap; +import java.util.Map; import org.openecomp.conflicts.types.Conflict; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.datatypes.model.ElementType; import org.openecomp.sdcrests.conflict.types.ConflictDto; import org.openecomp.sdcrests.mapping.EchoMapMapping; import org.openecomp.sdcrests.mapping.MappingBase; -import org.openecomp.sdcrests.vendorlicense.rest.mapping.*; -import org.openecomp.sdcrests.vendorlicense.types.*; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; -import org.openecomp.sdcrests.vsp.rest.mapping.*; - -import java.util.AbstractMap; -import java.util.HashMap; -import java.util.Map; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapEntitlementPoolEntityToEntitlementPoolEntityDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapFeatureGroupEntityToFeatureGroupDescriptorDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseAgreementEntityToLicenseAgreementDescriptorDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLimitEntityToLimitDto; +import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapVendorLicenseModelEntityToDto; +import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupDescriptorDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementDescriptorDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.FileDataStructureDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDependencyModelEntityToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentEntityToComponentDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToVspComputeDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorEntityToDeploymentFlavorDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapFilesDataStructureToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapImageEntityToImageDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkEntityToNetworkDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNicEntityToNicDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapProcessEntityToProcessEntityDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireToQuestionnaireDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDetailsToDto; public class MapConflictToDto extends MappingBase<Conflict, ConflictDto> { - @Override - public void doMapping(Conflict source, ConflictDto target) { - target.setId(source.getId()); - target.setType(source.getType()); - target.setName(source.getName()); - - Map.Entry<MappingBase, Class> mapperToTargetClass = getMapper(source.getType()); - target.setTheirs(map(mapperToTargetClass, source.getTheirs())); - target.setYours(map(mapperToTargetClass, source.getYours())); - } + @Override + public void doMapping(Conflict source, ConflictDto target) { + target.setId(source.getId()); + target.setType(source.getType()); + target.setName(source.getName()); + Map.Entry<MappingBase, Class> mapperToTargetClass = getMapper(source.getType()); + target.setTheirs(map(mapperToTargetClass, source.getTheirs())); + target.setYours(map(mapperToTargetClass, source.getYours())); + } - private Map map(Map.Entry<MappingBase, Class> mapperToTargetClass, Object object) { - return JsonUtil - .json2Object(JsonUtil.object2Json( - mapperToTargetClass.getKey().applyMapping(object, mapperToTargetClass.getValue())), - Map.class); - } + private Map map(Map.Entry<MappingBase, Class> mapperToTargetClass, Object object) { + return JsonUtil + .json2Object(JsonUtil.object2Json(mapperToTargetClass.getKey().applyMapping(object, mapperToTargetClass.getValue())), Map.class); + } - private Map.Entry<MappingBase, Class> getMapper(ElementType type) { - switch (type) { - case VendorLicenseModel: - return new AbstractMap.SimpleEntry<>(new MapVendorLicenseModelEntityToDto(), - VendorLicenseModelEntityDto.class); - case LicenseAgreement: - return new AbstractMap.SimpleEntry<>( - new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto(), - LicenseAgreementDescriptorDto.class); - case FeatureGroup: - return new AbstractMap.SimpleEntry<>(new MapFeatureGroupEntityToFeatureGroupDescriptorDto(), - FeatureGroupDescriptorDto.class); - case LicenseKeyGroup: - return new AbstractMap.SimpleEntry<>( - new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(), LicenseKeyGroupEntityDto - .class); - case EntitlementPool: - return new AbstractMap.SimpleEntry<>( - new MapEntitlementPoolEntityToEntitlementPoolEntityDto(), EntitlementPoolEntityDto - .class); - case Limit: - return new AbstractMap.SimpleEntry<>(new MapLimitEntityToLimitDto(), LimitEntityDto.class); - case VendorSoftwareProduct: - return new AbstractMap.SimpleEntry<>(new MapVspDetailsToDto(), VspDetailsDto.class); - case Network: - return new AbstractMap.SimpleEntry<>(new MapNetworkEntityToNetworkDto(), NetworkDto.class); - case Component: - return new AbstractMap.SimpleEntry<>(new MapComponentEntityToComponentDto(), - ComponentDto.class); - case ComponentDependencies: - return new AbstractMap.SimpleEntry<>(new MapComponentDependencyModelEntityToDto(), - ComponentDependencyModel.class); - case Nic: - return new AbstractMap.SimpleEntry<>(new MapNicEntityToNicDto(), NicDto.class); - case Process: - return new AbstractMap.SimpleEntry<>(new MapProcessEntityToProcessEntityDto(), - ProcessEntityDto.class); - case DeploymentFlavor: - return new AbstractMap.SimpleEntry<>(new MapDeploymentFlavorEntityToDeploymentFlavorDto(), - DeploymentFlavorDto.class); - case Compute: - return new AbstractMap.SimpleEntry<>(new MapComputeEntityToVspComputeDto(), - VspComputeDto.class); - case Image: - return new AbstractMap.SimpleEntry<>(new MapImageEntityToImageDto(), ImageDto.class); - case VSPQuestionnaire: - case NicQuestionnaire: - case ComponentQuestionnaire: - case ImageQuestionnaire: - case ComputeQuestionnaire: - return new AbstractMap.SimpleEntry<>(new MapQuestionnaireToQuestionnaireDto(), - QuestionnaireDto.class); - case SNMP_POLL: - case SNMP_TRAP: - case VES_EVENTS: - case OrchestrationTemplateCandidate: - return new AbstractMap.SimpleEntry<>(new MapFilesDataStructureToDto(), - FileDataStructureDto.class); - case ServiceModel: - case NetworkPackage: - return new AbstractMap.SimpleEntry<>(new EchoMapMapping(), HashMap.class); - case itemVersion: - return new AbstractMap.SimpleEntry<>(new EchoMapMapping(), HashMap.class); + private Map.Entry<MappingBase, Class> getMapper(ElementType type) { + switch (type) { + case VendorLicenseModel: + return new AbstractMap.SimpleEntry<>(new MapVendorLicenseModelEntityToDto(), VendorLicenseModelEntityDto.class); + case LicenseAgreement: + return new AbstractMap.SimpleEntry<>(new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto(), + LicenseAgreementDescriptorDto.class); + case FeatureGroup: + return new AbstractMap.SimpleEntry<>(new MapFeatureGroupEntityToFeatureGroupDescriptorDto(), FeatureGroupDescriptorDto.class); + case LicenseKeyGroup: + return new AbstractMap.SimpleEntry<>(new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(), LicenseKeyGroupEntityDto.class); + case EntitlementPool: + return new AbstractMap.SimpleEntry<>(new MapEntitlementPoolEntityToEntitlementPoolEntityDto(), EntitlementPoolEntityDto.class); + case Limit: + return new AbstractMap.SimpleEntry<>(new MapLimitEntityToLimitDto(), LimitEntityDto.class); + case VendorSoftwareProduct: + return new AbstractMap.SimpleEntry<>(new MapVspDetailsToDto(), VspDetailsDto.class); + case Network: + return new AbstractMap.SimpleEntry<>(new MapNetworkEntityToNetworkDto(), NetworkDto.class); + case Component: + return new AbstractMap.SimpleEntry<>(new MapComponentEntityToComponentDto(), ComponentDto.class); + case ComponentDependencies: + return new AbstractMap.SimpleEntry<>(new MapComponentDependencyModelEntityToDto(), ComponentDependencyModel.class); + case Nic: + return new AbstractMap.SimpleEntry<>(new MapNicEntityToNicDto(), NicDto.class); + case Process: + return new AbstractMap.SimpleEntry<>(new MapProcessEntityToProcessEntityDto(), ProcessEntityDto.class); + case DeploymentFlavor: + return new AbstractMap.SimpleEntry<>(new MapDeploymentFlavorEntityToDeploymentFlavorDto(), DeploymentFlavorDto.class); + case Compute: + return new AbstractMap.SimpleEntry<>(new MapComputeEntityToVspComputeDto(), VspComputeDto.class); + case Image: + return new AbstractMap.SimpleEntry<>(new MapImageEntityToImageDto(), ImageDto.class); + case VSPQuestionnaire: + case NicQuestionnaire: + case ComponentQuestionnaire: + case ImageQuestionnaire: + case ComputeQuestionnaire: + return new AbstractMap.SimpleEntry<>(new MapQuestionnaireToQuestionnaireDto(), QuestionnaireDto.class); + case SNMP_POLL: + case SNMP_TRAP: + case VES_EVENTS: + case OrchestrationTemplateCandidate: + return new AbstractMap.SimpleEntry<>(new MapFilesDataStructureToDto(), FileDataStructureDto.class); + case ServiceModel: + case NetworkPackage: + return new AbstractMap.SimpleEntry<>(new EchoMapMapping(), HashMap.class); + case itemVersion: + return new AbstractMap.SimpleEntry<>(new EchoMapMapping(), HashMap.class); + } + throw new RuntimeException("Get conflict does not support element type: " + type.name()); } - throw new RuntimeException("Get conflict does not support element type: " + type.name()); - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java index a2b70834c6..c439d5e7ba 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapDtoToConflictResolution.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,19 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.conflict.rest.mapping; import org.openecomp.conflicts.types.ConflictResolution; import org.openecomp.sdcrests.conflict.types.ConflictResolutionDto; import org.openecomp.sdcrests.mapping.MappingBase; -public class MapDtoToConflictResolution - extends MappingBase<ConflictResolutionDto, ConflictResolution> { +public class MapDtoToConflictResolution extends MappingBase<ConflictResolutionDto, ConflictResolution> { - @Override - public void doMapping(ConflictResolutionDto source, ConflictResolution target) { - target.setResolution(source.getResolution()); - target.setOtherResolution(source.getOtherResolution()); - } + @Override + public void doMapping(ConflictResolutionDto source, ConflictResolution target) { + target.setResolution(source.getResolution()); + target.setOtherResolution(source.getOtherResolution()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java index 51201a884b..a3ae77fc79 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/mapping/MapItemVersionConflictToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,26 +17,21 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.conflict.rest.mapping; - import org.openecomp.conflicts.types.ItemVersionConflict; import org.openecomp.sdcrests.conflict.types.ConflictDto; import org.openecomp.sdcrests.conflict.types.ConflictInfoDto; import org.openecomp.sdcrests.conflict.types.ItemVersionConflictDto; import org.openecomp.sdcrests.mapping.MappingBase; -public class MapItemVersionConflictToDto - extends MappingBase<ItemVersionConflict, ItemVersionConflictDto> { - - @Override - public void doMapping(ItemVersionConflict source, ItemVersionConflictDto target) { - target - .setConflict(new MapConflictToDto().applyMapping(source.getVersionConflict(), ConflictDto.class)); +public class MapItemVersionConflictToDto extends MappingBase<ItemVersionConflict, ItemVersionConflictDto> { - MapConflictInfoToDto conflictInfoMapper = new MapConflictInfoToDto(); - source.getElementConflicts().forEach(conflictInfo -> target - .addConflictInfo(conflictInfoMapper.applyMapping(conflictInfo, ConflictInfoDto.class))); - } + @Override + public void doMapping(ItemVersionConflict source, ItemVersionConflictDto target) { + target.setConflict(new MapConflictToDto().applyMapping(source.getVersionConflict(), ConflictDto.class)); + MapConflictInfoToDto conflictInfoMapper = new MapConflictInfoToDto(); + source.getElementConflicts() + .forEach(conflictInfo -> target.addConflictInfo(conflictInfoMapper.applyMapping(conflictInfo, ConflictInfoDto.class))); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java index 994c29afb1..61225b5d6f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-services/src/main/java/org/openecomp/sdcrests/conflict/rest/services/ConflictsImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,10 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.conflict.rest.services; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.conflicts.types.Conflict; import org.openecomp.conflicts.types.ConflictResolution; import org.openecomp.conflicts.types.ItemVersionConflict; @@ -36,47 +37,34 @@ import org.openecomp.sdcrests.conflict.types.ItemVersionConflictDto; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; - @Named @Service("conflicts") @Scope(value = "prototype") public class ConflictsImpl implements Conflicts { - @Override - public Response getConflict(String itemId, String versionId, String user) { - - ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface(); - ItemVersionConflict itemVersionConflict = conflictsManager.getConflict - (itemId, new Version(versionId)); - ItemVersionConflictDto result = (new MapItemVersionConflictToDto()).applyMapping - (itemVersionConflict, ItemVersionConflictDto.class); - return Response.ok(result).build(); - } - - @Override - public Response getConflict(String itemId, String versionId, String conflictId, String user) { - ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface(); - Conflict conflict = conflictsManager.getConflict(itemId, new Version(versionId), conflictId); - - ConflictDto result = new MapConflictToDto().applyMapping(conflict, ConflictDto.class); - - return Response.ok(result).build(); - - } - - @Override - public Response resolveConflict(ConflictResolutionDto conflictResolution, String itemId, - String versionId, String conflictId, String user) { - ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface(); + @Override + public Response getConflict(String itemId, String versionId, String user) { + ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface(); + ItemVersionConflict itemVersionConflict = conflictsManager.getConflict(itemId, new Version(versionId)); + ItemVersionConflictDto result = (new MapItemVersionConflictToDto()).applyMapping(itemVersionConflict, ItemVersionConflictDto.class); + return Response.ok(result).build(); + } - Version version = new Version(versionId); - conflictsManager.resolveConflict(itemId, version, conflictId, - new MapDtoToConflictResolution() - .applyMapping(conflictResolution, ConflictResolution.class)); - conflictsManager.finalizeMerge(itemId, version); + @Override + public Response getConflict(String itemId, String versionId, String conflictId, String user) { + ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface(); + Conflict conflict = conflictsManager.getConflict(itemId, new Version(versionId), conflictId); + ConflictDto result = new MapConflictToDto().applyMapping(conflict, ConflictDto.class); + return Response.ok(result).build(); + } - return Response.ok().build(); - } + @Override + public Response resolveConflict(ConflictResolutionDto conflictResolution, String itemId, String versionId, String conflictId, String user) { + ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface(); + Version version = new Version(versionId); + conflictsManager.resolveConflict(itemId, version, conflictId, + new MapDtoToConflictResolution().applyMapping(conflictResolution, ConflictResolution.class)); + conflictsManager.finalizeMerge(itemId, version); + return Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictDto.java index 004517434e..e7179fd6a3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,28 +17,28 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.conflict.types; import java.util.Map; public class ConflictDto extends ConflictInfoDto { - private Map<String, Object> yours; - private Map<String, Object> theirs; - public Map<String, Object> getYours() { - return yours; - } + private Map<String, Object> yours; + private Map<String, Object> theirs; + + public Map<String, Object> getYours() { + return yours; + } - public void setYours(Map<String, Object> yours) { - this.yours = yours; - } + public void setYours(Map<String, Object> yours) { + this.yours = yours; + } - public Map<String, Object> getTheirs() { - return theirs; - } + public Map<String, Object> getTheirs() { + return theirs; + } - public void setTheirs(Map<String, Object> theirs) { - this.theirs = theirs; - } + public void setTheirs(Map<String, Object> theirs) { + this.theirs = theirs; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictInfoDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictInfoDto.java index 659ca46c8f..320fc3de61 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictInfoDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictInfoDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,37 +17,37 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.conflict.types; import org.openecomp.sdc.datatypes.model.ElementType; public class ConflictInfoDto { - private String id; - private ElementType type; - private String name; - public String getId() { - return id; - } + private String id; + private ElementType type; + private String name; + + public String getId() { + return id; + } - public void setId(String id) { - this.id = id; - } + public void setId(String id) { + this.id = id; + } - public ElementType getType() { - return type; - } + public ElementType getType() { + return type; + } - public void setType(ElementType type) { - this.type = type; - } + public void setType(ElementType type) { + this.type = type; + } - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictResolutionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictResolutionDto.java index 8983c91924..6d3ca38a03 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictResolutionDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ConflictResolutionDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,31 +17,30 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.conflict.types; -import org.openecomp.conflicts.types.Resolution; - import java.util.Map; +import org.openecomp.conflicts.types.Resolution; public class ConflictResolutionDto { - private Resolution resolution; - // sits in lower level... - private Map<String, Object> otherResolution; - public Resolution getResolution() { - return resolution; - } + private Resolution resolution; + // sits in lower level... + private Map<String, Object> otherResolution; + + public Resolution getResolution() { + return resolution; + } - public void setResolution(Resolution resolution) { - this.resolution = resolution; - } + public void setResolution(Resolution resolution) { + this.resolution = resolution; + } - public Map<String, Object> getOtherResolution() { - return otherResolution; - } + public Map<String, Object> getOtherResolution() { + return otherResolution; + } - public void setOtherResolution(Map<String, Object> otherResolution) { - this.otherResolution = otherResolution; - } + public void setOtherResolution(Map<String, Object> otherResolution) { + this.otherResolution = otherResolution; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ItemVersionConflictDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ItemVersionConflictDto.java index 005689450a..2eea6edc7a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ItemVersionConflictDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/conflict-rest/conflict-rest-types/src/main/java/org/openecomp/sdcrests/conflict/types/ItemVersionConflictDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,33 +17,33 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.conflict.types; import java.util.ArrayList; import java.util.Collection; -public class ItemVersionConflictDto{ - private ConflictDto conflict; - private Collection<ConflictInfoDto> conflictInfoList = new ArrayList<>(); +public class ItemVersionConflictDto { + + private ConflictDto conflict; + private Collection<ConflictInfoDto> conflictInfoList = new ArrayList<>(); - public ConflictDto getConflict() { - return conflict; - } + public ConflictDto getConflict() { + return conflict; + } - public void setConflict(ConflictDto conflict) { - this.conflict = conflict; - } + public void setConflict(ConflictDto conflict) { + this.conflict = conflict; + } - public Collection<ConflictInfoDto> getConflictInfoList() { - return conflictInfoList; - } + public Collection<ConflictInfoDto> getConflictInfoList() { + return conflictInfoList; + } - public void setConflictInfoList(Collection<ConflictInfoDto> conflictInfoList) { - this.conflictInfoList = conflictInfoList; - } + public void setConflictInfoList(Collection<ConflictInfoDto> conflictInfoList) { + this.conflictInfoList = conflictInfoList; + } - public void addConflictInfo(ConflictInfoDto conflictInfo){ - conflictInfoList.add(conflictInfo); - } + public void addConflictInfo(ConflictInfoDto conflictInfo) { + conflictInfoList.add(conflictInfo); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java index 2a9e0a24de..31cfabdba4 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/HealthCheck.java @@ -17,25 +17,22 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.health.rest; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.health.types.HealthInfoDtos; -import org.springframework.validation.annotation.Validated; - import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.openecomp.sdcrests.health.types.HealthInfoDtos; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/healthcheck") @Produces(MediaType.APPLICATION_JSON) @@ -44,8 +41,7 @@ import javax.ws.rs.core.Response; @Validated public interface HealthCheck { - @GET - @Operation(description = "Perform health check", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = HealthInfoDtos.class)))) - Response checkHealth(); - + @GET + @Operation(description = "Perform health check", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = HealthInfoDtos.class)))) + Response checkHealth(); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDto.java index 8d560027e5..1b5c690d3b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/mapping/MapHealthCheckInfoToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.health.rest.mapping; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; import org.openecomp.sdc.health.data.HealthInfo; import org.openecomp.sdcrests.health.types.HealthCheckStatus; import org.openecomp.sdcrests.health.types.HealthInfoDto; @@ -27,23 +29,17 @@ import org.openecomp.sdcrests.health.types.HealthInfoDtos; import org.openecomp.sdcrests.health.types.MonitoredModules; import org.openecomp.sdcrests.mapping.MappingBase; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; - /** * Created by Talio on 8/10/2016. */ -public class MapHealthCheckInfoToDto - extends MappingBase<Collection<HealthInfo>, HealthInfoDtos> { +public class MapHealthCheckInfoToDto extends MappingBase<Collection<HealthInfo>, HealthInfoDtos> { + @Override public void doMapping(Collection<HealthInfo> source, HealthInfoDtos target) { - - List<HealthInfoDto> healthInfos = source.stream() - .map(healthInfo -> new HealthInfoDto( - MonitoredModules.toValue(healthInfo.getHealthCheckComponent().toString()), - HealthCheckStatus.valueOf(healthInfo.getHealthCheckStatus().toString()), - healthInfo.getVersion(), healthInfo.getDescription())).collect(Collectors.toList()); + List<HealthInfoDto> healthInfos = source.stream().map( + healthInfo -> new HealthInfoDto(MonitoredModules.toValue(healthInfo.getHealthCheckComponent().toString()), + HealthCheckStatus.valueOf(healthInfo.getHealthCheckStatus().toString()), healthInfo.getVersion(), healthInfo.getDescription())) + .collect(Collectors.toList()); target.setHealthInfos(healthInfos); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java index 57ebb1f3f7..aa1cb5711c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-services/src/main/java/org/openecomp/sdcrests/health/rest/services/HealthCheckImpl.java @@ -17,9 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.health.rest.services; +import java.util.Arrays; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.impl.ResponseBuilderImpl; import org.openecomp.sdc.common.session.SessionContextProviderFactory; import org.openecomp.sdc.health.HealthCheckManager; @@ -32,60 +35,45 @@ import org.openecomp.sdc.logging.api.LoggerFactory; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Arrays; -import java.util.Collection; - @Named @Service("healthCheck") @Scope(value = "prototype") public class HealthCheckImpl implements org.openecomp.sdcrests.health.rest.HealthCheck { - private HealthCheckManager healthCheckManager; - private static final Logger logger = LoggerFactory.getLogger(HealthCheckImpl.class); + private static final Logger logger = LoggerFactory.getLogger(HealthCheckImpl.class); + private HealthCheckManager healthCheckManager; - public HealthCheckImpl() { - try { - healthCheckManager = HealthCheckManagerFactory.getInstance().createInterface(); - } catch (Exception e) { - logger.error(e.getMessage(), e); + public HealthCheckImpl() { + try { + healthCheckManager = HealthCheckManagerFactory.getInstance().createInterface(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } } - } - - @Override - public Response checkHealth() { - HealthCheckResult healthCheckResult = new HealthCheckResult(); - - SessionContextProviderFactory.getInstance().createInterface().create("public", "dox"); - try { - Collection<HealthInfo> healthInfos = healthCheckManager.checkHealth(); - healthCheckResult.setComponentsInfo(healthInfos); - boolean someIsDown = healthInfos.stream() - .anyMatch(healthInfo -> healthInfo.getHealthCheckStatus().equals(HealthCheckStatus.DOWN)); - healthInfos.stream() - .filter(healthInfo -> healthInfo.getHealthCheckComponent() - .equals(org.openecomp.sdc.health.data.MonitoredModules.BE)) - .findFirst() - .ifPresent(healthInfo -> healthCheckResult.setSdcVersion(healthInfo.getVersion())); - if (someIsDown) { - Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl(); - return responseBuilder.entity(healthCheckResult).status(500).build(); - } - return Response.ok(healthCheckResult).build(); - } catch (Exception ex) { - logger.error("Health check failed", ex); - Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl(); - HealthInfo healthInfo = new HealthInfo(org.openecomp.sdc.health.data.MonitoredModules.BE, - HealthCheckStatus.DOWN, - "", "Failed to perform Health Check"); - Collection<HealthInfo> healthInfos = Arrays.asList(healthInfo); - healthCheckResult.setComponentsInfo(healthInfos); - return responseBuilder.entity(healthCheckResult).status(500).build(); + @Override + public Response checkHealth() { + HealthCheckResult healthCheckResult = new HealthCheckResult(); + SessionContextProviderFactory.getInstance().createInterface().create("public", "dox"); + try { + Collection<HealthInfo> healthInfos = healthCheckManager.checkHealth(); + healthCheckResult.setComponentsInfo(healthInfos); + boolean someIsDown = healthInfos.stream().anyMatch(healthInfo -> healthInfo.getHealthCheckStatus().equals(HealthCheckStatus.DOWN)); + healthInfos.stream().filter(healthInfo -> healthInfo.getHealthCheckComponent().equals(org.openecomp.sdc.health.data.MonitoredModules.BE)) + .findFirst().ifPresent(healthInfo -> healthCheckResult.setSdcVersion(healthInfo.getVersion())); + if (someIsDown) { + Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl(); + return responseBuilder.entity(healthCheckResult).status(500).build(); + } + return Response.ok(healthCheckResult).build(); + } catch (Exception ex) { + logger.error("Health check failed", ex); + Response.ResponseBuilder responseBuilder = new ResponseBuilderImpl(); + HealthInfo healthInfo = new HealthInfo(org.openecomp.sdc.health.data.MonitoredModules.BE, HealthCheckStatus.DOWN, "", + "Failed to perform Health Check"); + Collection<HealthInfo> healthInfos = Arrays.asList(healthInfo); + healthCheckResult.setComponentsInfo(healthInfos); + return responseBuilder.entity(healthCheckResult).status(500).build(); + } } - } - - } - diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthCheckStatus.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthCheckStatus.java index ff19640ee8..de333d269d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthCheckStatus.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthCheckStatus.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,32 +17,27 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.health.types; - public enum HealthCheckStatus { - UP("UP"), - DOWN("DOWN"); - + UP("UP"), DOWN("DOWN"); private String name; HealthCheckStatus(String name) { this.name = name; } - - @Override - public String toString() { - return name; - } - - public static final HealthCheckStatus toValue(String inVal){ - for (HealthCheckStatus val : values()){ - if (val.toString().equals(inVal)){ + public static final HealthCheckStatus toValue(String inVal) { + for (HealthCheckStatus val : values()) { + if (val.toString().equals(inVal)) { return val; } } return null; } + + @Override + public String toString() { + return name; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthInfoDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthInfoDto.java index 012a9f329b..16453ff12d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthInfoDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthInfoDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,11 +17,10 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.health.types; - public class HealthInfoDto { + private MonitoredModules healthCheckComponent; private HealthCheckStatus healthStatus; private String version; @@ -71,11 +70,7 @@ public class HealthInfoDto { @Override public String toString() { - return "HealthInfo{" + - "healthCheckComponent='" + healthCheckComponent + '\'' + - ", healthStatus=" + healthStatus + - ", version='" + version + '\'' + - ", description='" + description + '\'' + - '}'; + return "HealthInfo{" + "healthCheckComponent='" + healthCheckComponent + '\'' + ", healthStatus=" + healthStatus + ", version='" + version + + '\'' + ", description='" + description + '\'' + '}'; } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthInfoDtos.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthInfoDtos.java index 709320df57..99a861f1f7 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthInfoDtos.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/HealthInfoDtos.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,14 +17,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.health.types; - import java.util.List; import java.util.stream.Collectors; public class HealthInfoDtos { + private List<HealthInfoDto> healthInfos; public HealthInfoDtos() { @@ -44,8 +43,6 @@ public class HealthInfoDtos { @Override public String toString() { - return healthInfos.stream().map(healthInfoDto -> healthInfoDto.toString()) - .collect(Collectors.joining(", ")); - + return healthInfos.stream().map(healthInfoDto -> healthInfoDto.toString()).collect(Collectors.joining(", ")); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/MonitoredModules.java b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/MonitoredModules.java index b2519d5854..74b4a439e3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/MonitoredModules.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/healthcheck-rest/healthcheck-rest-types/src/main/java/org/openecomp/sdcrests/health/types/MonitoredModules.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,33 +17,27 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.health.types; - public enum MonitoredModules { - BE("BE"), - CAS("Cassandra"), - ZU("Zusammen"); - + BE("BE"), CAS("Cassandra"), ZU("Zusammen"); private String name; MonitoredModules(String name) { this.name = name; } - - @Override - public String toString() { - return name; - } - - public static final MonitoredModules toValue(String inVal){ - for (MonitoredModules val : values()){ - if (val.toString().equals(inVal)){ + public static final MonitoredModules toValue(String inVal) { + for (MonitoredModules val : values()) { + if (val.toString().equals(inVal)) { return val; } } return null; } + + @Override + public String toString() { + return name; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java index c3ebc31b08..4343c1a000 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/ItemPermissions.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,30 +17,32 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.itempermissions.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsDto; -import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsRequestDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsDto; +import org.openecomp.sdcrests.itempermissions.types.ItemPermissionsRequestDto; +import org.springframework.validation.annotation.Validated; /** * Created by ayalaben on 6/18/2017. @@ -52,19 +54,15 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface ItemPermissions { - @GET - @Path("/") - @Operation(description = "List users permissions assigned on item",responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ItemPermissionsDto.class))))) - Response list(@PathParam("itemId") String itemId, - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @PUT - @Path("/{permission}") - @Operation(description = "Update useres permission on item") - Response updatePermissions(@Valid ItemPermissionsRequestDto request, - @PathParam("itemId") String itemId, - @PathParam("permission") String permission, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "List users permissions assigned on item", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ItemPermissionsDto.class))))) + Response list(@PathParam("itemId") String itemId, @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{permission}") + @Operation(description = "Update useres permission on item") + Response updatePermissions(@Valid ItemPermissionsRequestDto request, @PathParam("itemId") String itemId, + @PathParam("permission") String permission, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java index c578cbe699..97011ef4c9 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/mapping/MapItemPermissionsToItemPermissionsDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.itempermissions.rest.mapping; import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity; @@ -27,14 +26,11 @@ import org.openecomp.sdcrests.mapping.MappingBase; /** * Created by ayalaben on 6/18/2017. */ +public class MapItemPermissionsToItemPermissionsDto extends MappingBase<ItemPermissionsEntity, ItemPermissionsDto> { -public class MapItemPermissionsToItemPermissionsDto extends - MappingBase<ItemPermissionsEntity, ItemPermissionsDto> { - - - @Override - public void doMapping(ItemPermissionsEntity source, ItemPermissionsDto target) { - target.setUserId(source.getUserId()); - target.setPermission(source.getPermission()); - } + @Override + public void doMapping(ItemPermissionsEntity source, ItemPermissionsDto target) { + target.setUserId(source.getUserId()); + target.setPermission(source.getPermission()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java index 213af650f7..ece235a29a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-services/src/main/java/org/openecomp/sdcrests/itempermissions/rest/services/ItemPermissionsImpl.java @@ -15,7 +15,8 @@ */ package org.openecomp.sdcrests.itempermissions.rest.services; - +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.sdc.itempermissions.PermissionsManager; import org.openecomp.sdc.itempermissions.PermissionsManagerFactory; import org.openecomp.sdcrests.itempermissions.rest.ItemPermissions; @@ -26,41 +27,28 @@ import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; - /** * Created by ayalaben on 6/18/2017. */ - @Named @Service("itemPermissions") @Scope(value = "prototype") public class ItemPermissionsImpl implements ItemPermissions { - private PermissionsManager permissionsManager = - PermissionsManagerFactory.getInstance().createInterface(); - - @Override - public Response list(String itemId, String user) { - - GenericCollectionWrapper<ItemPermissionsDto> results = new GenericCollectionWrapper<>(); - MapItemPermissionsToItemPermissionsDto mapper = new MapItemPermissionsToItemPermissionsDto(); - - permissionsManager.listItemPermissions(itemId) - .forEach(itemPermission -> results.add(mapper.applyMapping - (itemPermission, ItemPermissionsDto.class))); - - return Response.ok(results).build(); - } - - @Override - public Response updatePermissions(ItemPermissionsRequestDto request, String itemId, - String permission, String user) { - - permissionsManager.updateItemPermissions(itemId,permission,request.getAddedUsersIds(), - request.getRemovedUsersIds()); - - return Response.ok().build(); - } + private PermissionsManager permissionsManager = PermissionsManagerFactory.getInstance().createInterface(); + + @Override + public Response list(String itemId, String user) { + GenericCollectionWrapper<ItemPermissionsDto> results = new GenericCollectionWrapper<>(); + MapItemPermissionsToItemPermissionsDto mapper = new MapItemPermissionsToItemPermissionsDto(); + permissionsManager.listItemPermissions(itemId) + .forEach(itemPermission -> results.add(mapper.applyMapping(itemPermission, ItemPermissionsDto.class))); + return Response.ok(results).build(); + } + + @Override + public Response updatePermissions(ItemPermissionsRequestDto request, String itemId, String permission, String user) { + permissionsManager.updateItemPermissions(itemId, permission, request.getAddedUsersIds(), request.getRemovedUsersIds()); + return Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java index ef56619ff6..be3790b6e0 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.itempermissions.types; /** @@ -25,23 +24,22 @@ package org.openecomp.sdcrests.itempermissions.types; */ public class ItemPermissionsDto { - private String userId; - private String permission; - - public String getUserId() { - return userId; - } + private String userId; + private String permission; - public void setUserId(String id) { - this.userId = id; - } + public String getUserId() { + return userId; + } - public String getPermission() { - return permission; - } + public void setUserId(String id) { + this.userId = id; + } - public void setPermission(String permission) { - this.permission = permission; - } + public String getPermission() { + return permission; + } + public void setPermission(String permission) { + this.permission = permission; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java index 873ff5d49e..1353b58d70 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-permissions-rest/item-permissions-rest-types/src/main/java/org/openecomp/sdcrests/itempermissions/types/ItemPermissionsRequestDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,38 +17,33 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.itempermissions.types; - - import io.swagger.v3.oas.annotations.media.Schema; - import java.util.Set; /** * Created by ayalaben on 6/20/2017. */ - @Schema(description = "ItemPermissionsRequest") public class ItemPermissionsRequestDto { - private Set<String> addedUsersIds; - private Set<String> removedUsersIds; + private Set<String> addedUsersIds; + private Set<String> removedUsersIds; - public Set<String> getAddedUsersIds() { - return addedUsersIds; - } + public Set<String> getAddedUsersIds() { + return addedUsersIds; + } - public void setAddedUsersIds(Set<String> addedUsersIds) { - this.addedUsersIds = addedUsersIds; - } + public void setAddedUsersIds(Set<String> addedUsersIds) { + this.addedUsersIds = addedUsersIds; + } - public Set<String> getRemovedUsersIds() { - return removedUsersIds; - } + public Set<String> getRemovedUsersIds() { + return removedUsersIds; + } - public void setRemovedUsersIds(Set<String> removedUsersIds) { - this.removedUsersIds = removedUsersIds; - } + public void setRemovedUsersIds(Set<String> removedUsersIds) { + this.removedUsersIds = removedUsersIds; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Items.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Items.java index ae8e095acb..066acb9370 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Items.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Items.java @@ -15,27 +15,31 @@ */ package org.openecomp.sdcrests.item.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdc.versioning.types.Item; -import org.openecomp.sdcrests.item.types.ItemActionRequestDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +import org.openecomp.sdc.versioning.types.Item; +import org.openecomp.sdcrests.item.types.ItemActionRequestDto; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/items") @Produces(MediaType.APPLICATION_JSON) @@ -57,23 +61,16 @@ public interface Items { @QueryParam("permission") String permissionFilter, @Parameter(description = "Filter by onboarding method", schema = @Schema(type = "string", allowableValues = {"NetworkPackage", "manual"})) @QueryParam("onboardingMethod") String onboardingMethodFilter, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @Path("/{itemId}") @Operation(description = "Get details of a item") - Response getItem(@PathParam("itemId") String itemId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + Response getItem(@PathParam("itemId") String itemId, @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @Path("/{itemId}/actions") @Operation(description = "Acts on item version") - Response actOn(ItemActionRequestDto request, - @PathParam("itemId") String itemId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - + Response actOn(ItemActionRequestDto request, @PathParam("itemId") String itemId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java index edc0596282..0335f894b8 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/Versions.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,28 +17,35 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.item.types.*; -import org.springframework.validation.annotation.Validated; - import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +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 static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +import org.openecomp.sdcrests.item.types.ActivityLogDto; +import org.openecomp.sdcrests.item.types.VersionActionRequestDto; +import org.openecomp.sdcrests.item.types.VersionDto; +import org.openecomp.sdcrests.item.types.VersionRequestDto; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/items/{itemId}/versions") @Produces(MediaType.APPLICATION_JSON) @@ -47,52 +54,39 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface Versions { - @GET - @Path("/") - @Operation(description = "Lists item versions", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = VersionDto.class))))) - Response list(@PathParam("itemId") String itemId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "Lists item versions", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = VersionDto.class))))) + Response list(@PathParam("itemId") String itemId, @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/{versionId}") - @Operation(description = "Creates a new item version") - Response create(VersionRequestDto request, - @PathParam("itemId") String itemId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @POST + @Path("/{versionId}") + @Operation(description = "Creates a new item version") + Response create(VersionRequestDto request, @PathParam("itemId") String itemId, @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{versionId}") - @Operation(description = "Gets item version", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = VersionDto.class)))) - Response get(@PathParam("itemId") String itemId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{versionId}") + @Operation(description = "Gets item version", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = VersionDto.class)))) + Response get(@PathParam("itemId") String itemId, @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{versionId}/activity-logs") - @Operation(description = "Gets item version activity log", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = ActivityLogDto.class))))) - Response getActivityLog(@Parameter(description = "Item Id") @PathParam("itemId") String itemId, - @Parameter( description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{versionId}/activity-logs") + @Operation(description = "Gets item version activity log", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ActivityLogDto.class))))) + Response getActivityLog(@Parameter(description = "Item Id") @PathParam("itemId") String itemId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{versionId}/revisions") - @Operation(description = "Gets item version revisions", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = ActivityLogDto.class))))) - Response listRevisions(@PathParam("itemId") String itemId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{versionId}/revisions") + @Operation(description = "Gets item version revisions", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ActivityLogDto.class))))) + Response listRevisions(@PathParam("itemId") String itemId, @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{versionId}/actions") - @Operation(description = "Acts on item version") - Response actOn(VersionActionRequestDto request, - @PathParam("itemId") String itemId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{versionId}/actions") + @Operation(description = "Acts on item version") + Response actOn(VersionActionRequestDto request, @PathParam("itemId") String itemId, @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/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java index 307b555720..633da0a92a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapActivityLogEntityToDto.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.rest.mapping; import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; @@ -25,17 +24,15 @@ import org.openecomp.sdcrests.item.types.ActivityLogDto; import org.openecomp.sdcrests.item.types.ActivityStatus; import org.openecomp.sdcrests.mapping.MappingBase; -public class MapActivityLogEntityToDto - extends MappingBase<ActivityLogEntity, ActivityLogDto> { - +public class MapActivityLogEntityToDto extends MappingBase<ActivityLogEntity, ActivityLogDto> { - @Override - public void doMapping(ActivityLogEntity source, ActivityLogDto target) { - target.setId(source.getId()); - target.setTimestamp(source.getTimestamp()); - target.setType(source.getType().name()); - target.setComment(source.getComment()); - target.setUser(source.getUser()); - target.setStatus(new ActivityStatus(source.isSuccess(), source.getMessage())); - } + @Override + public void doMapping(ActivityLogEntity source, ActivityLogDto target) { + target.setId(source.getId()); + target.setTimestamp(source.getTimestamp()); + target.setType(source.getType().name()); + target.setComment(source.getComment()); + target.setUser(source.getUser()); + target.setStatus(new ActivityStatus(source.isSuccess(), source.getMessage())); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java index 68bd9a51fb..3bd8a7fe9f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapItemToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.rest.mapping; import org.openecomp.sdc.versioning.types.Item; @@ -25,14 +24,15 @@ import org.openecomp.sdcrests.item.types.ItemDto; import org.openecomp.sdcrests.mapping.MappingBase; public class MapItemToDto extends MappingBase<Item, ItemDto> { - @Override - public void doMapping(Item source, ItemDto target) { - target.setId(source.getId()); - target.setType(source.getType()); - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setOwner(source.getOwner()); - target.setStatus(source.getStatus().name()); - target.setProperties(source.getProperties()); - } + + @Override + public void doMapping(Item source, ItemDto target) { + target.setId(source.getId()); + target.setType(source.getType()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setOwner(source.getOwner()); + target.setStatus(source.getStatus().name()); + target.setProperties(source.getProperties()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java index b66b289ce9..13838f794b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapRevisionToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.rest.mapping; import org.openecomp.sdc.versioning.dao.types.Revision; @@ -25,11 +24,12 @@ import org.openecomp.sdcrests.item.types.RevisionDto; import org.openecomp.sdcrests.mapping.MappingBase; public class MapRevisionToDto extends MappingBase<Revision, RevisionDto> { - @Override - public void doMapping(Revision source, RevisionDto target) { - target.setId(source.getId()); - target.setMessage(source.getMessage()); - target.setUser(source.getUser()); - target.setTime(source.getTime()); - } + + @Override + public void doMapping(Revision source, RevisionDto target) { + target.setId(source.getId()); + target.setMessage(source.getMessage()); + target.setUser(source.getUser()); + target.setTime(source.getTime()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java index a29ac8acf6..382b85a761 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/mapping/MapVersionToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.rest.mapping; import org.openecomp.sdc.versioning.dao.types.Version; @@ -25,16 +24,17 @@ import org.openecomp.sdcrests.item.types.VersionDto; import org.openecomp.sdcrests.mapping.MappingBase; public class MapVersionToDto extends MappingBase<Version, VersionDto> { - @Override - public void doMapping(Version source, VersionDto target) { - target.setId(source.getId()); - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setBaseId(source.getBaseId()); - target.setStatus(source.getStatus()); - target.setState(source.getState()); - target.setCreationTime(source.getCreationTime()); - target.setModificationTime(source.getModificationTime()); - target.setAdditionalInfo(source.getAdditionalInfo()); - } + + @Override + public void doMapping(Version source, VersionDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setBaseId(source.getBaseId()); + target.setStatus(source.getStatus()); + target.setState(source.getState()); + target.setCreationTime(source.getCreationTime()); + target.setModificationTime(source.getModificationTime()); + target.setAdditionalInfo(source.getAdditionalInfo()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/models/SyncEvent.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/models/SyncEvent.java index c057ecf7e0..716ae8dcf3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/models/SyncEvent.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/models/SyncEvent.java @@ -55,5 +55,4 @@ public class SyncEvent implements Event { public String getEntityId() { return entityId; } - -}
\ No newline at end of file +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java index 4c1a0fb659..f18de66863 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ItemsImpl.java @@ -13,10 +13,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.item.rest.services; +import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME; + import com.google.common.annotations.VisibleForTesting; +import java.util.Arrays; +import java.util.Collections; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import javax.annotation.PostConstruct; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; import org.openecomp.sdc.activitylog.dao.type.ActivityType; import org.openecomp.sdc.datatypes.model.ItemType; @@ -42,17 +59,6 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import javax.annotation.PostConstruct; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.*; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; -import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID; -import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME; - @Named @Service("items") @Scope(value = "prototype") @@ -61,26 +67,21 @@ public class ItemsImpl implements Items { private static final String ONBOARDING_METHOD = "onboardingMethod"; private static final Logger LOGGER = LoggerFactory.getLogger(ItemsImpl.class); - private Map<ItemAction, ActionSideAffects> actionSideAffectsMap = new EnumMap<>(ItemAction.class); private ManagersProvider managersProvider; @PostConstruct public void initActionSideAffectsMap() { - actionSideAffectsMap - .put(ItemAction.ARCHIVE, new ActionSideAffects(ActivityType.Archive, NotificationEventTypes.ARCHIVE)); - actionSideAffectsMap - .put(ItemAction.RESTORE, new ActionSideAffects(ActivityType.Restore, NotificationEventTypes.RESTORE)); + actionSideAffectsMap.put(ItemAction.ARCHIVE, new ActionSideAffects(ActivityType.Archive, NotificationEventTypes.ARCHIVE)); + actionSideAffectsMap.put(ItemAction.RESTORE, new ActionSideAffects(ActivityType.Restore, NotificationEventTypes.RESTORE)); } @Override public Response actOn(ItemActionRequestDto request, String itemId, String user) { - Item item = getManagersProvider().getItemManager().get(itemId); if (item == null) { return Response.status(Response.Status.NOT_FOUND).entity(new Exception("Item does not exist.")).build(); } - switch (request.getAction()) { case ARCHIVE: getManagersProvider().getItemManager().archive(item); @@ -90,7 +91,6 @@ public class ItemsImpl implements Items { break; default: } - actionSideAffectsMap.get(request.getAction()).execute(item, user); try { Notifier catalogNotifier = NotifierFactory.getInstance(); @@ -98,81 +98,32 @@ public class ItemsImpl implements Items { } catch (Exception e) { LOGGER.error("Failed to send catalog notification on item {}", itemId, e); } - return Response.ok().build(); } @Override - public Response list(String itemStatusFilter, String versionStatusFilter, String itemTypeFilter, - String permissionFilter, String onboardingMethodFilter, String user) { - - Predicate<Item> itemPredicate = - createItemPredicate(itemStatusFilter, versionStatusFilter, itemTypeFilter, onboardingMethodFilter, - permissionFilter, user); - + public Response list(String itemStatusFilter, String versionStatusFilter, String itemTypeFilter, String permissionFilter, + String onboardingMethodFilter, String user) { + Predicate<Item> itemPredicate = createItemPredicate(itemStatusFilter, versionStatusFilter, itemTypeFilter, onboardingMethodFilter, + permissionFilter, user); GenericCollectionWrapper<ItemDto> results = new GenericCollectionWrapper<>(); MapItemToDto mapper = new MapItemToDto(); getManagersProvider().getItemManager().list(itemPredicate).stream() - .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())) - .forEach(item -> results.add(mapper.applyMapping(item, ItemDto.class))); - + .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())) + .forEach(item -> results.add(mapper.applyMapping(item, ItemDto.class))); return Response.ok(results).build(); - } @Override public Response getItem(String itemId, String user) { Item item = getManagersProvider().getItemManager().get(itemId); ItemDto itemDto = new MapItemToDto().applyMapping(item, ItemDto.class); - return Response.ok(itemDto).build(); } - private class ActionSideAffects { - - private ActivityType activityType; - private NotificationEventTypes notificationType; - - private ActionSideAffects(ActivityType activityType, NotificationEventTypes notificationType) { - this.activityType = activityType; - this.notificationType = notificationType; - - } - - private Version getLatestVersion(String itemId) { - List<Version> list = getManagersProvider().getVersioningManager().list(itemId); - Optional<Version> max = list.stream().max(Version::compareTo); - - return max.orElse(null); - } - - private void execute(Item item, String user) { - notifyUsers(item.getId(), item.getName(), user, this.notificationType); - getManagersProvider().getActivityLogManager().logActivity( - new ActivityLogEntity(item.getId(), getLatestVersion(item.getId()), this.activityType, user, true, - "", "")); - } - - private void notifyUsers(String itemId, String itemName, String userName, NotificationEventTypes eventType) { - Map<String, Object> eventProperties = new HashMap<>(); - eventProperties.put(ITEM_NAME, itemName == null ? getManagersProvider().getItemManager().get(itemId).getName() : itemName); - eventProperties.put(ITEM_ID, itemId); - - eventProperties.put(PERMISSION_USER, userName); - - Event syncEvent = new SyncEvent(eventType.getEventName(), itemId, eventProperties, itemId); - try { - getManagersProvider().getNotificationPropagationManager().notifySubscribers(syncEvent, userName); - } catch (Exception e) { - LOGGER.error("Failed to send sync notification to users subscribed to item '{}'", itemId, e); - } - } - } - - private Predicate<Item> createItemPredicate(String itemStatusFilter, String versionStatusFilter, - String itemTypeFilter, String onboardingMethodFilter, String permissionsFilter, String user) { + private Predicate<Item> createItemPredicate(String itemStatusFilter, String versionStatusFilter, String itemTypeFilter, + String onboardingMethodFilter, String permissionsFilter, String user) { Predicate<Item> itemPredicate = item -> true; - if (itemStatusFilter != null) { validateItemStatusValue(itemStatusFilter); itemPredicate = itemPredicate.and(createItemStatusPredicate(itemStatusFilter)); @@ -205,8 +156,7 @@ public class ItemsImpl implements Items { } private Predicate<Item> createVersionStatusPredicate(String filterValue) { - Set<VersionStatus> versionStatuses = - Arrays.stream(filterValue.split(",")).map(VersionStatus::valueOf).collect(Collectors.toSet()); + Set<VersionStatus> versionStatuses = Arrays.stream(filterValue.split(",")).map(VersionStatus::valueOf).collect(Collectors.toSet()); return item -> item.getVersionStatusCounters().keySet().stream().anyMatch(versionStatuses::contains); } @@ -215,9 +165,8 @@ public class ItemsImpl implements Items { } private Predicate<Item> createOnboardingMethodPredicate(String filterValue) { - return item -> !ItemType.vsp.name().equals(item.getType()) || ((String) item.getProperties() - .get(ONBOARDING_METHOD)) - .matches(formatFilter(filterValue)); + return item -> !ItemType.vsp.name().equals(item.getType()) || ((String) item.getProperties().get(ONBOARDING_METHOD)) + .matches(formatFilter(filterValue)); } private Predicate<Item> createPermissionsPredicate(String user, String filterValue) { @@ -241,7 +190,6 @@ public class ItemsImpl implements Items { for (String value : values) { VersionStatus.valueOf(value); } - } private void validateItemTypeValue(String itemTypeFilter) { @@ -265,26 +213,59 @@ public class ItemsImpl implements Items { } } - //Do not delete - is in use, duplicates code to prevent dependency on openecomp-sdc-vendor-software-product-api - private enum OnboardingMethod { - NetworkPackage, Manual - } - - @VisibleForTesting - void setManagersProvider(ManagersProvider managersProvider) { - this.managersProvider = managersProvider; - } - @VisibleForTesting Map<ItemAction, ActionSideAffects> getActionSideAffectsMap() { return actionSideAffectsMap; } private ManagersProvider getManagersProvider() { - if (managersProvider == null){ + if (managersProvider == null) { managersProvider = new ManagersProvider(); } return managersProvider; } + @VisibleForTesting + void setManagersProvider(ManagersProvider managersProvider) { + this.managersProvider = managersProvider; + } + + //Do not delete - is in use, duplicates code to prevent dependency on openecomp-sdc-vendor-software-product-api + private enum OnboardingMethod {NetworkPackage, Manual} + + private class ActionSideAffects { + + private ActivityType activityType; + private NotificationEventTypes notificationType; + + private ActionSideAffects(ActivityType activityType, NotificationEventTypes notificationType) { + this.activityType = activityType; + this.notificationType = notificationType; + } + + private Version getLatestVersion(String itemId) { + List<Version> list = getManagersProvider().getVersioningManager().list(itemId); + Optional<Version> max = list.stream().max(Version::compareTo); + return max.orElse(null); + } + + private void execute(Item item, String user) { + notifyUsers(item.getId(), item.getName(), user, this.notificationType); + getManagersProvider().getActivityLogManager() + .logActivity(new ActivityLogEntity(item.getId(), getLatestVersion(item.getId()), this.activityType, user, true, "", "")); + } + + private void notifyUsers(String itemId, String itemName, String userName, NotificationEventTypes eventType) { + Map<String, Object> eventProperties = new HashMap<>(); + eventProperties.put(ITEM_NAME, itemName == null ? getManagersProvider().getItemManager().get(itemId).getName() : itemName); + eventProperties.put(ITEM_ID, itemId); + eventProperties.put(PERMISSION_USER, userName); + Event syncEvent = new SyncEvent(eventType.getEventName(), itemId, eventProperties, itemId); + try { + getManagersProvider().getNotificationPropagationManager().notifySubscribers(syncEvent, userName); + } catch (Exception e) { + LOGGER.error("Failed to send sync notification to users subscribed to item '{}'", itemId, e); + } + } + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ManagersProvider.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ManagersProvider.java index 9d2ca6ef57..8db02f777f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ManagersProvider.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/ManagersProvider.java @@ -37,12 +37,12 @@ import org.openecomp.sdc.versioning.VersioningManagerFactory; @Getter class ManagersProvider { + private PermissionsManager permissionsManager = PermissionsManagerFactory.getInstance().createInterface(); private AsdcItemManager asdcItemManager = AsdcItemManagerFactory.getInstance().createInterface(); private VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface(); private ConflictsManager conflictsManager = ConflictsManagerFactory.getInstance().createInterface(); private ActivityLogManager activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); - private NotificationPropagationManager notificationPropagationManager = NotificationPropagationManagerFactory - .getInstance().createInterface(); + private NotificationPropagationManager notificationPropagationManager = NotificationPropagationManagerFactory.getInstance().createInterface(); private ItemManager itemManager = ItemManagerFactory.getInstance().createInterface(); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java index 114a97a039..6e7703cda3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/VersionsImpl.java @@ -13,29 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.item.rest.services; +import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME; + import com.google.common.annotations.VisibleForTesting; -import org.openecomp.sdc.activitylog.ActivityLogManager; -import org.openecomp.sdc.activitylog.ActivityLogManagerFactory; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; import org.openecomp.sdc.activitylog.dao.type.ActivityType; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.Messages; -import org.openecomp.sdc.conflicts.ConflictsManager; -import org.openecomp.sdc.conflicts.ConflictsManagerFactory; -import org.openecomp.sdc.itempermissions.PermissionsManager; -import org.openecomp.sdc.itempermissions.PermissionsManagerFactory; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.notification.dtos.Event; -import org.openecomp.sdc.notification.factories.NotificationPropagationManagerFactory; -import org.openecomp.sdc.notification.services.NotificationPropagationManager; -import org.openecomp.sdc.versioning.AsdcItemManager; -import org.openecomp.sdc.versioning.AsdcItemManagerFactory; -import org.openecomp.sdc.versioning.VersioningManager; -import org.openecomp.sdc.versioning.VersioningManagerFactory; import org.openecomp.sdc.versioning.dao.types.Revision; import org.openecomp.sdc.versioning.dao.types.SynchronizationState; import org.openecomp.sdc.versioning.dao.types.Version; @@ -47,20 +46,17 @@ import org.openecomp.sdcrests.item.rest.mapping.MapActivityLogEntityToDto; import org.openecomp.sdcrests.item.rest.mapping.MapRevisionToDto; import org.openecomp.sdcrests.item.rest.mapping.MapVersionToDto; import org.openecomp.sdcrests.item.rest.models.SyncEvent; -import org.openecomp.sdcrests.item.types.*; +import org.openecomp.sdcrests.item.types.ActivityLogDto; +import org.openecomp.sdcrests.item.types.CommitRequestDto; +import org.openecomp.sdcrests.item.types.RevisionDto; +import org.openecomp.sdcrests.item.types.RevisionRequestDto; +import org.openecomp.sdcrests.item.types.VersionActionRequestDto; +import org.openecomp.sdcrests.item.types.VersionDto; +import org.openecomp.sdcrests.item.types.VersionRequestDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; -import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.*; - @Named @Service("versions") @Scope(value = "prototype") @@ -68,16 +64,13 @@ public class VersionsImpl implements Versions { private static final String COMMIT_ITEM_ACTION = "Commit_Item"; private static final Logger LOGGER = LoggerFactory.getLogger(VersionsImpl.class); - private ManagersProvider managersProvider; @Override public Response list(String itemId, String user) { GenericCollectionWrapper<VersionDto> results = new GenericCollectionWrapper<>(); MapVersionToDto mapper = new MapVersionToDto(); - - getManagersProvider().getVersioningManager().list(itemId) - .forEach(version -> results.add(mapper.applyMapping(version, VersionDto.class))); + getManagersProvider().getVersioningManager().list(itemId).forEach(version -> results.add(mapper.applyMapping(version, VersionDto.class))); return Response.ok(results).build(); } @@ -86,15 +79,11 @@ public class VersionsImpl implements Versions { Version version = new Version(); version.setBaseId(baseVersionId); version.setDescription(request.getDescription()); - version = getManagersProvider().getVersioningManager() .create(itemId, version, VersionCreationMethod.valueOf(request.getCreationMethod().name())); - VersionDto versionDto = new MapVersionToDto().applyMapping(version, VersionDto.class); - - getManagersProvider().getActivityLogManager().logActivity( - new ActivityLogEntity(itemId, version, ActivityType.Create_Version, user, true, "", "")); - + getManagersProvider().getActivityLogManager() + .logActivity(new ActivityLogEntity(itemId, version, ActivityType.Create_Version, user, true, "", "")); return Response.ok(versionDto).build(); } @@ -109,10 +98,8 @@ public class VersionsImpl implements Versions { public Response getActivityLog(String itemId, String versionId, String user) { GenericCollectionWrapper<ActivityLogDto> results = new GenericCollectionWrapper<>(); MapActivityLogEntityToDto mapper = new MapActivityLogEntityToDto(); - getManagersProvider().getActivityLogManager().listLoggedActivities(itemId, new Version(versionId)) - .forEach(loggedActivity -> results.add(mapper.applyMapping(loggedActivity, ActivityLogDto.class))); - + .forEach(loggedActivity -> results.add(mapper.applyMapping(loggedActivity, ActivityLogDto.class))); return Response.ok(results).build(); } @@ -120,7 +107,6 @@ public class VersionsImpl implements Versions { public Response listRevisions(String itemId, String versionId, String user) { List<Revision> revisions = getManagersProvider().getVersioningManager().listRevisions(itemId, new Version(versionId)); filterRevisions(revisions); - GenericCollectionWrapper<RevisionDto> results = new GenericCollectionWrapper<>(); MapRevisionToDto mapper = new MapRevisionToDto(); revisions.forEach(revision -> results.add(mapper.applyMapping(revision, RevisionDto.class))); @@ -136,8 +122,7 @@ public class VersionsImpl implements Versions { break; case Commit: if (!getManagersProvider().getPermissionsManager().isAllowed(itemId, user, COMMIT_ITEM_ACTION)) { - return Response.status(Response.Status.FORBIDDEN) - .entity(new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build(); + return Response.status(Response.Status.FORBIDDEN).entity(new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build(); } commit(request.getCommitRequest(), itemId, version, user); break; @@ -155,10 +140,9 @@ public class VersionsImpl implements Versions { private Version getVersion(String itemId, Version version) { Version retrievedVersion = getManagersProvider().getVersioningManager().get(itemId, version); - if (retrievedVersion.getState().getSynchronizationState() != SynchronizationState.Merging && - // looks for sdc applicative conflicts - getManagersProvider().getConflictsManager().isConflicted(itemId, retrievedVersion)) { + // looks for sdc applicative conflicts + getManagersProvider().getConflictsManager().isConflicted(itemId, retrievedVersion)) { retrievedVersion.getState().setSynchronizationState(SynchronizationState.Merging); } return retrievedVersion; @@ -170,20 +154,17 @@ public class VersionsImpl implements Versions { } private void commit(CommitRequestDto request, String itemId, Version version, String user) { - String message = request == null ? "" : request.getMessage(); - getManagersProvider().getVersioningManager().publish(itemId, version, message); notifyUsers(itemId, version, message, user, NotificationEventTypes.COMMIT); - getManagersProvider().getActivityLogManager().logActivity( - new ActivityLogEntity(itemId, version, ActivityType.Commit, user, true, "", message)); + getManagersProvider().getActivityLogManager() + .logActivity(new ActivityLogEntity(itemId, version, ActivityType.Commit, user, true, "", message)); } private void revert(RevisionRequestDto request, String itemId, String versionId) { if (request.getRevisionId() == null) { throw new CoreException(new RevisionIdNotFoundErrorBuilder().build()); } - getManagersProvider().getVersioningManager().revert(itemId, new Version(versionId), request.getRevisionId()); } @@ -195,26 +176,20 @@ public class VersionsImpl implements Versions { 3- the second revision is in format "Initial <vlm/vsp>: <name of the vlm/vsp>" 4- only if a revision in this format exists we remove the first revision. */ int numOfRevisions = revisions.size(); - if (numOfRevisions > 1 && - - revisions.get(numOfRevisions - 2).getMessage().matches("Initial .*:.*")) { + if (numOfRevisions > 1 && revisions.get(numOfRevisions - 2).getMessage().matches("Initial .*:.*")) { revisions.remove(numOfRevisions - 1); } } - private void notifyUsers(String itemId, Version version, String message, String userName, - NotificationEventTypes eventType) { + private void notifyUsers(String itemId, Version version, String message, String userName, NotificationEventTypes eventType) { Map<String, Object> eventProperties = new HashMap<>(); eventProperties.put(ITEM_NAME, getManagersProvider().getAsdcItemManager().get(itemId).getName()); eventProperties.put(ITEM_ID, itemId); - Version ver = getManagersProvider().getVersioningManager().get(itemId, version); eventProperties.put(VERSION_NAME, ver.getName()); eventProperties.put(VERSION_ID, ver.getId()); - eventProperties.put(SUBMIT_DESCRIPTION, message); eventProperties.put(PERMISSION_USER, userName); - Event syncEvent = new SyncEvent(eventType.getEventName(), itemId, eventProperties, itemId); try { getManagersProvider().getNotificationPropagationManager().notifySubscribers(syncEvent, userName); @@ -223,16 +198,15 @@ public class VersionsImpl implements Versions { } } - @VisibleForTesting - void setManagersProvider(ManagersProvider managersProvider) { - this.managersProvider = managersProvider; - } - private ManagersProvider getManagersProvider() { - if (managersProvider == null){ + if (managersProvider == null) { managersProvider = new ManagersProvider(); } return managersProvider; } + @VisibleForTesting + void setManagersProvider(ManagersProvider managersProvider) { + this.managersProvider = managersProvider; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/AsyncNotifier.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/AsyncNotifier.java index 872c61e480..acdd1ae5aa 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/AsyncNotifier.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/AsyncNotifier.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.item.rest.services.catalog.notification; import java.util.Collection; @@ -38,21 +37,17 @@ import org.openecomp.sdcrests.item.types.ItemAction; public class AsyncNotifier implements Notifier { private static final ScheduledExecutorService EXECUTOR_SERVICE = Executors.newScheduledThreadPool(1); - private static final int DEFAULT_NUM_OF_RETRIES = 2; private static final long DEFAULT_INTERVAL = 5000; - private final BiFunction<Collection<String>, ItemAction, Callable<NextAction>> taskProducer; private final int numberOfRetries; private final long retryInterval; - AsyncNotifier(BiFunction<Collection<String>, ItemAction, Callable<NextAction>> taskProducer) { this(taskProducer, DEFAULT_NUM_OF_RETRIES, DEFAULT_INTERVAL); } - AsyncNotifier(BiFunction<Collection<String>, ItemAction, Callable<NextAction>> taskProducer, int numOfRetries, - long retryInterval) { + AsyncNotifier(BiFunction<Collection<String>, ItemAction, Callable<NextAction>> taskProducer, int numOfRetries, long retryInterval) { this.taskProducer = taskProducer; this.numberOfRetries = numOfRetries; this.retryInterval = retryInterval; @@ -60,30 +55,22 @@ public class AsyncNotifier implements Notifier { @Override public void execute(Collection<String> itemIds, ItemAction action) { - Callable<AsyncNotifier.NextAction> worker = taskProducer.apply(itemIds, action); - RetryingTask retryingTask = new RetryingTask(worker, numberOfRetries, retryInterval, EXECUTOR_SERVICE); - EXECUTOR_SERVICE.submit(LoggingContext.copyToCallable(retryingTask)); } - public enum NextAction { - RETRY, DONE - } + public enum NextAction {RETRY, DONE} static class RetryingTask implements Callable<Void> { private static final Logger LOGGER = LoggerFactory.getLogger(RetryingTask.class); - private final Callable<AsyncNotifier.NextAction> worker; private final long delay; private final ScheduledExecutorService scheduler; private final AtomicInteger retries; - RetryingTask(Callable<AsyncNotifier.NextAction> worker, int numOfRetries, long delay, - ScheduledExecutorService scheduler) { - + RetryingTask(Callable<AsyncNotifier.NextAction> worker, int numOfRetries, long delay, ScheduledExecutorService scheduler) { this.worker = Objects.requireNonNull(worker); this.retries = new AtomicInteger(requirePositiveRetries(numOfRetries)); this.delay = requirePositiveDelay(delay); @@ -91,38 +78,31 @@ public class AsyncNotifier implements Notifier { } private int requirePositiveRetries(int number) { - if (number < 1) { throw new IllegalArgumentException("Number of retries must be positive"); } - return number; } private long requirePositiveDelay(long number) { - if (number < 1) { throw new IllegalArgumentException("Delay must be positive"); } - return number; } @Override public Void call() throws Exception { - NextAction next = worker.call(); if (next == NextAction.DONE) { LOGGER.debug("Task successful: {}. Not going to retry", worker); return null; } - int attempts = retries.decrementAndGet(); if (attempts < 1) { LOGGER.warn("Exhausted number of retries for task {}, exiting", worker); return null; } - scheduler.schedule(this, delay, TimeUnit.MILLISECONDS); return null; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/EntryNotConfiguredException.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/EntryNotConfiguredException.java index 070164afe6..53ccac7503 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/EntryNotConfiguredException.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/EntryNotConfiguredException.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.item.rest.services.catalog.notification; /** diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/Notifier.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/Notifier.java index 9143de4212..dae07ebc05 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/Notifier.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/Notifier.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.item.rest.services.catalog.notification; import java.util.Collection; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/NotifierFactory.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/NotifierFactory.java index 462ffdf00c..f0bb1648dc 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/NotifierFactory.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/NotifierFactory.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.item.rest.services.catalog.notification; import com.fasterxml.jackson.databind.ObjectMapper; @@ -31,29 +30,27 @@ import org.openecomp.sdcrests.item.rest.services.catalog.notification.http.HttpT import org.openecomp.sdcrests.item.types.ItemAction; /** - * Creates an instance of {@link Notifier}, initialized according to current configuration. - * The configuration must be passed via the {@link #CONFIG_FILE_PROPERTY} JVM argument. + * Creates an instance of {@link Notifier}, initialized according to current configuration. The configuration must be passed via the {@link + * #CONFIG_FILE_PROPERTY} JVM argument. */ public class NotifierFactory { private static final Logger LOGGER = LoggerFactory.getLogger(NotifierFactory.class); - private static final String CONFIG_FILE_PROPERTY = "configuration.yaml"; private static final String CONFIG_SECTION = "catalogNotificationsConfig"; - private static final Notifier INSTANCE; - private NotifierFactory() { - // prevent instantiation - } - static { INSTANCE = createInstance(); } + private NotifierFactory() { + // prevent instantiation + } + /** - * Returns a {@link Notifier} instance according to the provided configuration. If no configuration was not - * provided, or the given configuration is incorrect, then an instance with reduced functionality will be returned. + * Returns a {@link Notifier} instance according to the provided configuration. If no configuration was not provided, or the given configuration + * is incorrect, then an instance with reduced functionality will be returned. * * @return available instance of {@link Notifier} */ @@ -62,18 +59,13 @@ public class NotifierFactory { } static Notifier createInstance() { - try { - String file = Objects.requireNonNull(System.getProperty(CONFIG_FILE_PROPERTY), - "Config file location must be specified via system property " + CONFIG_FILE_PROPERTY); - + "Config file location must be specified via system property " + CONFIG_FILE_PROPERTY); Object config = getNotificationConfiguration(file); ObjectMapper mapper = new ObjectMapper(); HttpConfiguration httpConfig = mapper.convertValue(config, HttpConfiguration.class); - return new AsyncNotifier(new HttpTaskProducer(httpConfig)); - } catch (Exception e) { LOGGER.warn("Failed to initialize notifier. Notifications will not be sent", e); return new UnsupportedConfigurationNotifier(); @@ -81,18 +73,15 @@ public class NotifierFactory { } private static Object getNotificationConfiguration(String file) throws IOException { - Map<?, ?> configuration = Objects.requireNonNull(readConfigurationFile(file), "Configuration cannot be empty"); Object notificationConfig = configuration.get(CONFIG_SECTION); if (notificationConfig == null) { throw new EntryNotConfiguredException(CONFIG_SECTION + " section"); } - return notificationConfig; } private static Map<?, ?> readConfigurationFile(String file) throws IOException { - try (InputStream fileInput = new FileInputStream(file)) { YamlUtil yamlUtil = new YamlUtil(); return yamlUtil.yamlToMap(fileInput); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/http/HttpConfiguration.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/http/HttpConfiguration.java index 4403bd840b..e10cd5d8c3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/http/HttpConfiguration.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/http/HttpConfiguration.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.item.rest.services.catalog.notification.http; import lombok.AllArgsConstructor; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/http/HttpNotificationTask.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/http/HttpNotificationTask.java index c88ac4ecce..1904bb5072 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/http/HttpNotificationTask.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/http/HttpNotificationTask.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.item.rest.services.catalog.notification.http; import static org.openecomp.sdcrests.item.rest.services.catalog.notification.AsyncNotifier.NextAction.DONE; @@ -42,8 +41,8 @@ import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdcrests.item.rest.services.catalog.notification.AsyncNotifier; /** - * HTTP client for notifying the Catalog of an action on items. The items are referenced by their IDs. The client can - * run multiple times, in which case only failed IDs will be re-attempted. + * HTTP client for notifying the Catalog of an action on items. The items are referenced by their IDs. The client can run multiple times, in which + * case only failed IDs will be re-attempted. * * @author evitaliy * @since 21 Nov 2018 @@ -52,10 +51,8 @@ import org.openecomp.sdcrests.item.rest.services.catalog.notification.AsyncNotif class HttpNotificationTask implements Callable<AsyncNotifier.NextAction> { private static final Logger LOGGER = LoggerFactory.getLogger(HttpNotificationTask.class); - private static final String APPLICATION_JSON = ContentType.APPLICATION_JSON.getMimeType(); private static final String USER_ID_HEADER_PARAM = "USER_ID"; - private final String endpoint; private final String userId; private volatile Collection<String> itemIds; @@ -68,59 +65,41 @@ class HttpNotificationTask implements Callable<AsyncNotifier.NextAction> { @Override public synchronized AsyncNotifier.NextAction call() { - try (CloseableHttpClient client = HttpClients.createDefault()) { - HttpPost request = createPostRequest(endpoint, itemIds, userId); - try (CloseableHttpResponse response = client.execute(request)) { - StatusLine status = response.getStatusLine(); - - LOGGER.debug("Catalog notification on VSP IDs: {}, endpoint: {}, response: {}", - itemIds, endpoint, status); - + LOGGER.debug("Catalog notification on VSP IDs: {}, endpoint: {}, response: {}", itemIds, endpoint, status); itemIds = getFailedIds(itemIds, response.getEntity()); - - if ((status.getStatusCode() == HttpStatus.SC_INTERNAL_SERVER_ERROR) - && (itemIds != null) && !itemIds.isEmpty()) { - + if ((status.getStatusCode() == HttpStatus.SC_INTERNAL_SERVER_ERROR) && (itemIds != null) && !itemIds.isEmpty()) { LOGGER.debug("Catalog notification on VSP IDs {} failed. Endpoint: {}. Retry", itemIds, endpoint); return RETRY; } - return DONE; } - } catch (Exception e) { LOGGER.error("Catalog notification on VSP IDs {} failed. Endpoint: {}", itemIds, endpoint, e); return DONE; } } - private HttpPost createPostRequest(String postUrl, Collection<String> itemIds, String userId) - throws UnsupportedEncodingException { - + private HttpPost createPostRequest(String postUrl, Collection<String> itemIds, String userId) throws UnsupportedEncodingException { HttpPost request = new HttpPost(postUrl); - request.addHeader(HttpHeaders.ACCEPT, APPLICATION_JSON); request.addHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON); request.addHeader(USER_ID_HEADER_PARAM, userId); - HttpEntity entity = new StringEntity(JsonUtil.object2Json(itemIds)); request.setEntity(entity); return request; } private Collection<String> getFailedIds(Collection<String> itemIds, HttpEntity responseBody) { - try { NotificationResponse response = JsonUtil.json2Object(responseBody.getContent(), NotificationResponse.class); return response != null ? response.failedIds : null; } catch (Exception e) { LOGGER.error("Error getting failed IDs from response", e); } - return itemIds; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/http/HttpTaskProducer.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/http/HttpTaskProducer.java index d210dc21af..694aa9241c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/http/HttpTaskProducer.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/catalog/notification/http/HttpTaskProducer.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.item.rest.services.catalog.notification.http; import java.util.Collection; @@ -35,11 +34,9 @@ import org.openecomp.sdcrests.item.types.ItemAction; * @author evitaliy * @since 21 Nov 2018 */ -public class HttpTaskProducer - implements BiFunction<Collection<String>, ItemAction, Callable<AsyncNotifier.NextAction>>, Notifier { +public class HttpTaskProducer implements BiFunction<Collection<String>, ItemAction, Callable<AsyncNotifier.NextAction>>, Notifier { private static final Logger LOGGER = LoggerFactory.getLogger(HttpTaskProducer.class); - private static final String CATALOG_HTTP_PROTOCOL = "HTTP"; private static final String CATALOG_HTTPS_PROTOCOL = "HTTPS"; private static final Map<ItemAction, String> ACTION_PATHS; @@ -66,16 +63,13 @@ public class HttpTaskProducer } private static String ensureEntryConfigured(String value, String entryName) { - if (value == null) { throw new EntryNotConfiguredException(entryName); } - return value; } private static String getPortConfiguration(String protocol, HttpConfiguration config) { - if (CATALOG_HTTP_PROTOCOL.equalsIgnoreCase(protocol)) { return ensureEntryConfigured(config.getCatalogBeHttpPort(), "HTTP port"); } else if (CATALOG_HTTPS_PROTOCOL.equalsIgnoreCase(protocol)) { @@ -85,6 +79,14 @@ public class HttpTaskProducer } } + static String getApiPath(ItemAction action) { + String path = ACTION_PATHS.get(action); + if (path == null) { + throw new IllegalArgumentException("Unsupported action: " + action.name()); + } + return path; + } + @Override public Callable<AsyncNotifier.NextAction> apply(Collection<String> itemIds, ItemAction action) { return createNotificationTask(itemIds, action); @@ -97,20 +99,9 @@ public class HttpTaskProducer return new HttpNotificationTask(notificationEndpoint, userId, itemIds); } - static String getApiPath(ItemAction action) { - - String path = ACTION_PATHS.get(action); - if (path == null) { - throw new IllegalArgumentException("Unsupported action: " + action.name()); - } - - return path; - } - @Override public void execute(Collection<String> itemIds, ItemAction action) { HttpNotificationTask task = createNotificationTask(itemIds, action); task.call(); } - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityLogDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityLogDto.java index 40fb91867e..a4b688085c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityLogDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ActivityLogDto.java @@ -17,69 +17,67 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.types; - import java.util.Date; public class ActivityLogDto { - private String id; - private Date timestamp; - private String type; - private String comment; - private String user; - private ActivityStatus status; + private String id; + private Date timestamp; + private String type; + private String comment; + private String user; + private ActivityStatus status; - public ActivityLogDto() { - } + public ActivityLogDto() { + } - public String getId() { - return id; - } + public String getId() { + return id; + } - public void setId(String id) { - this.id = id; - } + public void setId(String id) { + this.id = id; + } - public Date getTimestamp() { - return timestamp; - } + public Date getTimestamp() { + return timestamp; + } - public void setTimestamp(Date timestamp) { - this.timestamp = timestamp; - } + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } - public String getType() { - return type; - } + public String getType() { + return type; + } - public void setType(String type) { - this.type = type; - } + public void setType(String type) { + this.type = type; + } - public String getComment() { - return comment; - } + public String getComment() { + return comment; + } - public void setComment(String comment) { - this.comment = comment; - } + public void setComment(String comment) { + this.comment = comment; + } - public String getUser() { - return user; - } + public String getUser() { + return user; + } - public void setUser(String user) { - this.user = user; - } + public void setUser(String user) { + this.user = user; + } - public ActivityStatus getStatus() { - return status; - } + public ActivityStatus getStatus() { + return status; + } - public void setStatus(ActivityStatus status) { - this.status = status; - } + public void setStatus(ActivityStatus status) { + this.status = status; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/CommitRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/CommitRequestDto.java index 1c9a53de62..821b7713eb 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/CommitRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/CommitRequestDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,17 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.types; public class CommitRequestDto { - private String message; - public String getMessage() { - return message; - } + private String message; + + public String getMessage() { + return message; + } - public void setMessage(String message) { - this.message = message; - } + public void setMessage(String message) { + this.message = message; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemAction.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemAction.java index e82bc56100..2329302694 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemAction.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemAction.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,10 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.types; -public enum ItemAction { - ARCHIVE, - RESTORE -} +public enum ItemAction {ARCHIVE, RESTORE} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemActionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemActionRequestDto.java index 00032b62ab..d3e2041b8a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemActionRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemActionRequestDto.java @@ -16,14 +16,14 @@ package org.openecomp.sdcrests.item.types; public class ItemActionRequestDto { - private ItemAction action; - public ItemAction getAction() { - return action; - } + private ItemAction action; - public void setAction(ItemAction action) { - this.action = action; - } + public ItemAction getAction() { + return action; + } + public void setAction(ItemAction action) { + this.action = action; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemCreationDto.java index 8eff678a2c..dec7c97674 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemCreationDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,26 +17,26 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.types; public class ItemCreationDto { - private String itemId; - private VersionDto version; - public String getItemId() { - return itemId; - } + private String itemId; + private VersionDto version; + + public String getItemId() { + return itemId; + } - public void setItemId(String itemId) { - this.itemId = itemId; - } + public void setItemId(String itemId) { + this.itemId = itemId; + } - public VersionDto getVersion() { - return version; - } + public VersionDto getVersion() { + return version; + } - public void setVersion(VersionDto version) { - this.version = version; - } + public void setVersion(VersionDto version) { + this.version = version; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemDto.java index 64b68eb1cf..38633fb6f7 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/ItemDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,74 +17,73 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.types; import java.util.Map; public class ItemDto { - private String id; - private String type; - private String name; - private String description; - private String owner; - private String status; - private Map<String, Object> properties; - - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public Map<String, Object> getProperties() { - return properties; - } - - public void setProperties(Map<String, Object> properties) { - this.properties = properties; - } + + private String id; + private String type; + private String name; + private String description; + private String owner; + private String status; + private Map<String, Object> properties; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Map<String, Object> getProperties() { + return properties; + } + + public void setProperties(Map<String, Object> properties) { + this.properties = properties; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionDto.java index d3a7f95b86..d7bd88f4be 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,47 +17,46 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.types; import java.util.Date; public class RevisionDto { - private String id; - private String message; - private Date time; - private String user; - public String getId() { - return id; - } + private String id; + private String message; + private Date time; + private String user; - public void setId(String id) { - this.id = id; - } + public String getId() { + return id; + } - public void setMessage(String message) { - this.message = message; - } + public void setId(String id) { + this.id = id; + } - public void setTime(Date time) { - this.time = time; - } + public String getMessage() { + return message; + } - public String getMessage() { - return message; - } + public void setMessage(String message) { + this.message = message; + } - public Date getTime() { - return time; - } + public Date getTime() { + return time; + } - public String getUser() { - return user; - } + public void setTime(Date time) { + this.time = time; + } - public void setUser(String user) { - this.user = user; - } + public String getUser() { + return user; + } + public void setUser(String user) { + this.user = user; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionRequestDto.java index 516f0ea8e7..89631014ea 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/RevisionRequestDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,18 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.types; public class RevisionRequestDto { - private String revisionId; + private String revisionId; - public String getRevisionId() { - return revisionId; - } + public String getRevisionId() { + return revisionId; + } - public void setRevisionId(String revisionId) { - this.revisionId = revisionId; - } + public void setRevisionId(String revisionId) { + this.revisionId = revisionId; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/SubmitRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/SubmitRequestDto.java index 76500ca326..3f4b4a94da 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/SubmitRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/SubmitRequestDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,17 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.types; public class SubmitRequestDto { - private String message; - public String getMessage() { - return message; - } + private String message; + + public String getMessage() { + return message; + } - public void setMessage(String message) { - this.message = message; - } + public void setMessage(String message) { + this.message = message; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionAction.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionAction.java index 1dba03cedc..335eb15bf8 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionAction.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionAction.java @@ -17,13 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.types; -public enum VersionAction { - Sync, - Commit, - Revert, - Reset, - Clean -} +public enum VersionAction {Sync, Commit, Revert, Reset, Clean} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionActionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionActionRequestDto.java index 98a5bb94ee..a664318cd3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionActionRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionActionRequestDto.java @@ -17,36 +17,35 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.types; public class VersionActionRequestDto { - private VersionAction action; - private CommitRequestDto commitRequest; - private RevisionRequestDto revisionRequest; + private VersionAction action; + private CommitRequestDto commitRequest; + private RevisionRequestDto revisionRequest; - public VersionAction getAction() { - return action; - } + public VersionAction getAction() { + return action; + } - public void setAction(VersionAction action) { - this.action = action; - } + public void setAction(VersionAction action) { + this.action = action; + } - public CommitRequestDto getCommitRequest() { - return commitRequest; - } + public CommitRequestDto getCommitRequest() { + return commitRequest; + } - public void setCommitRequest(CommitRequestDto commitRequest) { - this.commitRequest = commitRequest; - } + public void setCommitRequest(CommitRequestDto commitRequest) { + this.commitRequest = commitRequest; + } - public RevisionRequestDto getRevisionRequest() { - return revisionRequest; - } + public RevisionRequestDto getRevisionRequest() { + return revisionRequest; + } - public void setRevisionRequest(RevisionRequestDto revisionRequest) { - this.revisionRequest = revisionRequest; - } + public void setRevisionRequest(RevisionRequestDto revisionRequest) { + this.revisionRequest = revisionRequest; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionDto.java index 8f3ce5dcad..83884d3a1d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,98 +17,97 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.types; -import org.openecomp.sdc.versioning.dao.types.VersionState; -import org.openecomp.sdc.versioning.dao.types.VersionStatus; - import java.util.Date; import java.util.Map; +import org.openecomp.sdc.versioning.dao.types.VersionState; +import org.openecomp.sdc.versioning.dao.types.VersionStatus; public class VersionDto { - private String id; - private String name; - private String description; - private String baseId; - private VersionStatus status; - private VersionState state; - private Date creationTime; - private Date modificationTime; - private Map<String,Object> additionalInfo; - public VersionDto() { - - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getBaseId() { - return baseId; - } - - public void setBaseId(String baseId) { - this.baseId = baseId; - } - - public VersionStatus getStatus() { - return status; - } - - public void setStatus(VersionStatus status) { - this.status = status; - } - - public VersionState getState() { - return state; - } - - public void setState(VersionState state) { - this.state = state; - } - - public Date getCreationTime() { - return creationTime; - } - - public void setCreationTime(Date creationTime) { - this.creationTime = creationTime; - } - - public Date getModificationTime() { - return modificationTime; - } - - public void setModificationTime(Date modificationTime) { - this.modificationTime = modificationTime; - } - - public Map<String, Object> getAdditionalInfo() { - return additionalInfo; - } - - public void setAdditionalInfo(Map<String, Object> additionalInfo) { - this.additionalInfo = additionalInfo; - } + + private String id; + private String name; + private String description; + private String baseId; + private VersionStatus status; + private VersionState state; + private Date creationTime; + private Date modificationTime; + private Map<String, Object> additionalInfo; + + public VersionDto() { + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getBaseId() { + return baseId; + } + + public void setBaseId(String baseId) { + this.baseId = baseId; + } + + public VersionStatus getStatus() { + return status; + } + + public void setStatus(VersionStatus status) { + this.status = status; + } + + public VersionState getState() { + return state; + } + + public void setState(VersionState state) { + this.state = state; + } + + public Date getCreationTime() { + return creationTime; + } + + public void setCreationTime(Date creationTime) { + this.creationTime = creationTime; + } + + public Date getModificationTime() { + return modificationTime; + } + + public void setModificationTime(Date modificationTime) { + this.modificationTime = modificationTime; + } + + public Map<String, Object> getAdditionalInfo() { + return additionalInfo; + } + + public void setAdditionalInfo(Map<String, Object> additionalInfo) { + this.additionalInfo = additionalInfo; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionRequestDto.java index 5c6e4848a0..81747d4612 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-types/src/main/java/org/openecomp/sdcrests/item/types/VersionRequestDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,28 +17,28 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.item.types; import org.openecomp.sdc.versioning.types.VersionCreationMethod; public class VersionRequestDto { - private String description; - private VersionCreationMethod creationMethod; - public String getDescription() { - return description; - } + private String description; + private VersionCreationMethod creationMethod; + + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public VersionCreationMethod getCreationMethod() { - return creationMethod; - } + public VersionCreationMethod getCreationMethod() { + return creationMethod; + } - public void setCreationMethod(VersionCreationMethod creationMethod) { - this.creationMethod = creationMethod; - } + public void setCreationMethod(VersionCreationMethod creationMethod) { + this.creationMethod = creationMethod; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java index 96300b5cbb..5007246ae1 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-fe/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java @@ -17,27 +17,24 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.server.listeners; - -import org.springframework.web.context.ContextLoaderListener; - import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; +import org.springframework.web.context.ContextLoaderListener; public class OnboardingAppStartupListener implements ServletContextListener { - ContextLoaderListener springListener; + ContextLoaderListener springListener; - @Override - public void contextInitialized(ServletContextEvent servletContextEvent) { - springListener = new ContextLoaderListener(); - springListener.initWebApplicationContext(servletContextEvent.getServletContext()); - } + @Override + public void contextInitialized(ServletContextEvent servletContextEvent) { + springListener = new ContextLoaderListener(); + springListener.initWebApplicationContext(servletContextEvent.getServletContext()); + } - @Override - public void contextDestroyed(ServletContextEvent servletContextEvent) { - springListener.closeWebApplicationContext(servletContextEvent.getServletContext()); - } + @Override + public void contextDestroyed(ServletContextEvent servletContextEvent) { + springListener.closeWebApplicationContext(servletContextEvent.getServletContext()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java index 41376b040f..be98d809de 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsStatusToDto.java @@ -17,10 +17,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.notifications.rest.mapping; import com.datastax.driver.core.utils.UUIDs; +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.notification.dao.types.NotificationEntity; import org.openecomp.sdc.notification.dtos.NotificationsStatus; @@ -28,37 +31,24 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.notifications.types.NotificationEntityDto; import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto; -import java.text.DateFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +public class MapNotificationsStatusToDto extends MappingBase<NotificationsStatus, NotificationsStatusDto> { -public class MapNotificationsStatusToDto - extends MappingBase<NotificationsStatus, NotificationsStatusDto> { - - private static final DateFormat formatter = - DateFormat.getDateTimeInstance(DateFormat.LONG, - DateFormat.SHORT); + private static final DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT); @Override public void doMapping(NotificationsStatus source, NotificationsStatusDto target) { - target.setLastScanned(source.getLastScanned()); target.setNewEntries(source.getNewEntries()); target.setEndOfPage(source.getEndOfPage()); target.setNumOfNotSeenNotifications(source.getNumOfNotSeenNotifications()); List<NotificationEntityDto> entityDtos = new ArrayList<>(); - source.getNotifications() - .forEach(notification -> entityDtos.add(new NotificationEntityDto(notification.isRead(), - notification.getEventId(), notification.getEventType(), - JsonUtil.json2Object(notification.getEventAttributes(), Map.class), - extractDate(notification)))); + source.getNotifications().forEach(notification -> entityDtos.add( + new NotificationEntityDto(notification.isRead(), notification.getEventId(), notification.getEventType(), + JsonUtil.json2Object(notification.getEventAttributes(), Map.class), extractDate(notification)))); target.setNotifications(entityDtos); } private String extractDate(NotificationEntity notification) { - return formatter.format(UUIDs.unixTimestamp - (notification - .getEventId())); + return formatter.format(UUIDs.unixTimestamp(notification.getEventId())); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java index 558453b7b6..a42f5f98da 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/mapping/MapNotificationsToDto.java @@ -17,10 +17,13 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.notifications.rest.mapping; import com.datastax.driver.core.utils.UUIDs; +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.notification.dao.types.NotificationEntity; @@ -28,30 +31,23 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.notifications.types.NotificationEntityDto; import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto; -import java.text.DateFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - public class MapNotificationsToDto extends MappingBase<List<NotificationEntity>, NotificationsStatusDto> { - private static final DateFormat formatter = - DateFormat.getDateTimeInstance(DateFormat.LONG, - DateFormat.SHORT); + + private static final DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT); + @Override public void doMapping(List<NotificationEntity> source, NotificationsStatusDto target) { List<NotificationEntityDto> entityDtos = new ArrayList<>(); - if(CollectionUtils.isNotEmpty(source)) { - source.forEach(notification -> entityDtos.add(new NotificationEntityDto(notification.isRead(), - notification.getEventId(), notification.getEventType(), JsonUtil.json2Object(notification.getEventAttributes(), Map.class), - extractDate(notification)))); + if (CollectionUtils.isNotEmpty(source)) { + source.forEach(notification -> entityDtos.add( + new NotificationEntityDto(notification.isRead(), notification.getEventId(), notification.getEventType(), + JsonUtil.json2Object(notification.getEventAttributes(), Map.class), extractDate(notification)))); target.setNotifications(entityDtos); target.setLastScanned(source.get(0).getEventId()); } } private String extractDate(NotificationEntity notification) { - return formatter.format(UUIDs.unixTimestamp - (notification - .getEventId())); + return formatter.format(UUIDs.unixTimestamp(notification.getEventId())); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java index b2e262e9ba..9a8d00c521 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/Notifications.java @@ -17,30 +17,36 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.notifications.rest.services; +import static org.openecomp.sdcrests.common.RestConstants.LAST_DELIVERED_QUERY_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.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto; -import org.openecomp.sdcrests.notifications.types.UpdateNotificationResponseStatus; -import org.springframework.validation.annotation.Validated; - +import java.lang.reflect.InvocationTargetException; +import java.util.UUID; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.lang.reflect.InvocationTargetException; -import java.util.UUID; - -import static org.openecomp.sdcrests.common.RestConstants.*; +import org.openecomp.sdcrests.notifications.types.NotificationsStatusDto; +import org.openecomp.sdcrests.notifications.types.UpdateNotificationResponseStatus; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/notifications") @Produces(MediaType.APPLICATION_JSON) @@ -48,38 +54,32 @@ import static org.openecomp.sdcrests.common.RestConstants.*; @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Notifications")}) @Validated public interface Notifications { - String LIMIT_QUERY_PARAM = "NOTIFICATION_ROWS_LIMIT"; - String END_OF_PAGE_QUERY_PARAM = "END_OF_PAGE_EVENT_ID"; - @GET - @Operation(description = "Retrieve all user notifications", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = NotificationsStatusDto.class))))) - Response getNotifications( - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user, - @QueryParam(LAST_DELIVERED_QUERY_PARAM) UUID lastDelvered, - @QueryParam(END_OF_PAGE_QUERY_PARAM) UUID endOfPage); + String LIMIT_QUERY_PARAM = "NOTIFICATION_ROWS_LIMIT"; + String END_OF_PAGE_QUERY_PARAM = "END_OF_PAGE_EVENT_ID"; - @PUT - @Path("/{notificationId}") - @Operation(description = "Mark notification as read", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = UpdateNotificationResponseStatus.class)))) - Response markAsRead( - @Parameter(description = "Notification Id") @PathParam("notificationId") String notificationId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws InvocationTargetException, IllegalAccessException; + @GET + @Operation(description = "Retrieve all user notifications", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = NotificationsStatusDto.class))))) + Response getNotifications(@NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user, + @QueryParam(LAST_DELIVERED_QUERY_PARAM) UUID lastDelvered, @QueryParam(END_OF_PAGE_QUERY_PARAM) UUID endOfPage); - @PUT - @Path("/last-seen/{notificationId}") - @Operation(description = "Update Last Seen Notification", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = UpdateNotificationResponseStatus.class)))) - Response updateLastSeenNotification( - @Parameter(description = "Notification Id") @PathParam("notificationId") String notificationId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws InvocationTargetException, IllegalAccessException; + @PUT + @Path("/{notificationId}") + @Operation(description = "Mark notification as read", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = UpdateNotificationResponseStatus.class)))) + Response markAsRead(@Parameter(description = "Notification Id") @PathParam("notificationId") String notificationId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws InvocationTargetException, IllegalAccessException; - @GET - @Path("/worker") - @Operation(description = "Retrive user not delivered notifications",responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = NotificationsStatusDto.class))))) - Response getNewNotificationsByOwnerId( - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user, - @QueryParam(LAST_DELIVERED_QUERY_PARAM) String eventId, - @QueryParam(LIMIT_QUERY_PARAM) String limit); + @PUT + @Path("/last-seen/{notificationId}") + @Operation(description = "Update Last Seen Notification", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = UpdateNotificationResponseStatus.class)))) + Response updateLastSeenNotification(@Parameter(description = "Notification Id") @PathParam("notificationId") String notificationId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws InvocationTargetException, IllegalAccessException; + @GET + @Path("/worker") + @Operation(description = "Retrive user not delivered notifications", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = NotificationsStatusDto.class))))) + Response getNewNotificationsByOwnerId(@NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user, + @QueryParam(LAST_DELIVERED_QUERY_PARAM) String eventId, @QueryParam(LIMIT_QUERY_PARAM) String limit); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java index bc33784bc8..4463717910 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-services/src/main/java/org/openecomp/sdcrests/notifications/rest/services/impl/NotificationsImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,14 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.notifications.rest.services.impl; +import java.lang.reflect.InvocationTargetException; +import java.util.List; +import java.util.Objects; +import java.util.UUID; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.sdc.common.errors.Messages; import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.datatypes.error.ErrorMessage; @@ -38,13 +43,6 @@ import org.openecomp.sdcrests.notifications.types.UpdateNotificationResponseStat import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.lang.reflect.InvocationTargetException; -import java.util.List; -import java.util.Objects; -import java.util.UUID; - /** * @author Avrahamg * @since June 22, 2017 @@ -54,54 +52,41 @@ import java.util.UUID; @Scope(value = "prototype") public class NotificationsImpl implements Notifications { - private static int selectionLimit = 10; - - private static final Logger LOGGER = LoggerFactory.getLogger(NotificationsImpl.class); - private NotificationsService notificationsService = NotificationsServiceFactory.getInstance().createInterface(); + private static final Logger LOGGER = LoggerFactory.getLogger(NotificationsImpl.class); + private static int selectionLimit = 10; + private NotificationsService notificationsService = NotificationsServiceFactory.getInstance().createInterface(); @Override public Response getNotifications(String user, UUID lastDelivered, UUID endOfPage) { - NotificationsStatus notificationsStatus = notificationsService - .getNotificationsStatus(user, lastDelivered, selectionLimit, endOfPage); + NotificationsStatus notificationsStatus = notificationsService.getNotificationsStatus(user, lastDelivered, selectionLimit, endOfPage); MapNotificationsStatusToDto converter = new MapNotificationsStatusToDto(); NotificationsStatusDto notificationsStatusDto = new NotificationsStatusDto(); converter.doMapping(notificationsStatus, notificationsStatusDto); - return Response.ok(notificationsStatusDto).build(); } @Override - public Response updateLastSeenNotification(String notificationId, String user) - throws InvocationTargetException, IllegalAccessException { - UpdateNotificationResponseStatus - updateNotificationResponseStatus = new UpdateNotificationResponseStatus(); + public Response updateLastSeenNotification(String notificationId, String user) throws InvocationTargetException, IllegalAccessException { + UpdateNotificationResponseStatus updateNotificationResponseStatus = new UpdateNotificationResponseStatus(); try { notificationsService.updateLastSeenNotification(user, UUID.fromString(notificationId)); } catch (Exception ex) { - LOGGER.error( - String.format(Messages.FAILED_TO_UPDATE_LAST_SEEN_NOTIFICATION.getErrorMessage(), - user), ex); + LOGGER.error(String.format(Messages.FAILED_TO_UPDATE_LAST_SEEN_NOTIFICATION.getErrorMessage(), user), ex); updateNotificationResponseStatus.addStructureError(notificationId, - new ErrorMessage(ErrorLevel.ERROR, - Messages.FAILED_TO_UPDATE_LAST_SEEN_NOTIFICATION.getErrorMessage())); + new ErrorMessage(ErrorLevel.ERROR, Messages.FAILED_TO_UPDATE_LAST_SEEN_NOTIFICATION.getErrorMessage())); } return Response.ok(updateNotificationResponseStatus).build(); } @Override - public Response markAsRead(String notificationId, String user) - throws InvocationTargetException, IllegalAccessException { - - UpdateNotificationResponseStatus - updateNotificationResponseStatus = new UpdateNotificationResponseStatus(); + public Response markAsRead(String notificationId, String user) throws InvocationTargetException, IllegalAccessException { + UpdateNotificationResponseStatus updateNotificationResponseStatus = new UpdateNotificationResponseStatus(); try { notificationsService.markAsRead(user, notificationId); } catch (NotificationNotExistException ex) { LOGGER.error(Messages.FAILED_TO_MARK_NOTIFICATION_AS_READ.getErrorMessage(), ex); - updateNotificationResponseStatus.addStructureError( - notificationId, new ErrorMessage(ErrorLevel.ERROR, Messages - .FAILED_TO_MARK_NOTIFICATION_AS_READ - .getErrorMessage())); + updateNotificationResponseStatus.addStructureError(notificationId, + new ErrorMessage(ErrorLevel.ERROR, Messages.FAILED_TO_MARK_NOTIFICATION_AS_READ.getErrorMessage())); } return Response.ok(updateNotificationResponseStatus).build(); } @@ -109,24 +94,18 @@ public class NotificationsImpl implements Notifications { @Override public Response getNewNotificationsByOwnerId(String user, String eventId, String limitStr) { int limit = selectionLimit; - if (Objects.nonNull(limitStr)) { try { limit = Integer.parseInt(limitStr); - } - catch (NumberFormatException f) { + } catch (NumberFormatException f) { LOGGER.error("Non numeric selection list size value specified: " + limitStr); } } - - List<NotificationEntity> notifications = Objects.isNull(eventId) - ? notificationsService.getNotificationsByOwnerId(user, limit) + List<NotificationEntity> notifications = Objects.isNull(eventId) ? notificationsService.getNotificationsByOwnerId(user, limit) : notificationsService.getNewNotificationsByOwnerId(user, UUID.fromString(eventId), limit); - MapNotificationsToDto converter = new MapNotificationsToDto(); NotificationsStatusDto notificationsStatusDto = new NotificationsStatusDto(); converter.doMapping(notifications, notificationsStatusDto); - return Response.ok(notificationsStatusDto).build(); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java index d41deb3a4d..f76c9566ec 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationEntityDto.java @@ -17,75 +17,74 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.notifications.types; import java.util.Map; import java.util.UUID; public class NotificationEntityDto { - private boolean read; - private UUID eventId; - private String dateTime; - private String eventType; - private Map<String, Object> eventAttributes; - - public NotificationEntityDto() { - } - public NotificationEntityDto(boolean read, UUID eventId, String eventType, - Map<String, Object> eventAttributes) { - this.read = read; - this.eventId = eventId; - this.eventType = eventType; - this.eventAttributes = eventAttributes; - } - - public NotificationEntityDto(boolean read, UUID eventId,String eventType, - Map<String, Object> eventAttributes, String dateTime) { - this.read = read; - this.eventId = eventId; - this.dateTime = dateTime; - this.eventType = eventType; - this.eventAttributes = eventAttributes; - } - - public boolean isRead() { - return read; - } - - public void setRead(boolean read) { - this.read = read; - } - - public UUID getEventId() { - return eventId; - } - - public void setEventId(UUID eventId) { - this.eventId = eventId; - } - - public String getEventType() { - return eventType; - } - - public void setEventType(String eventType) { - this.eventType = eventType; - } - - public Map<String, Object> getEventAttributes() { - return eventAttributes; - } - - public void setEventAttributes(Map<String, Object> eventAttributes) { - this.eventAttributes = eventAttributes; - } - - public String getDateTime() { - return dateTime; - } - - public void setDateTime(String dateTime) { - this.dateTime = dateTime; - } + + private boolean read; + private UUID eventId; + private String dateTime; + private String eventType; + private Map<String, Object> eventAttributes; + + public NotificationEntityDto() { + } + + public NotificationEntityDto(boolean read, UUID eventId, String eventType, Map<String, Object> eventAttributes) { + this.read = read; + this.eventId = eventId; + this.eventType = eventType; + this.eventAttributes = eventAttributes; + } + + public NotificationEntityDto(boolean read, UUID eventId, String eventType, Map<String, Object> eventAttributes, String dateTime) { + this.read = read; + this.eventId = eventId; + this.dateTime = dateTime; + this.eventType = eventType; + this.eventAttributes = eventAttributes; + } + + public boolean isRead() { + return read; + } + + public void setRead(boolean read) { + this.read = read; + } + + public UUID getEventId() { + return eventId; + } + + public void setEventId(UUID eventId) { + this.eventId = eventId; + } + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public Map<String, Object> getEventAttributes() { + return eventAttributes; + } + + public void setEventAttributes(Map<String, Object> eventAttributes) { + this.eventAttributes = eventAttributes; + } + + public String getDateTime() { + return dateTime; + } + + public void setDateTime(String dateTime) { + this.dateTime = dateTime; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java index a0273d51e0..fb4ed722b5 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationResponseStatus.java @@ -17,10 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.notifications.types; -public enum NotificationResponseStatus { - Success, - Failure -} +public enum NotificationResponseStatus {Success, Failure} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java index 7067fab509..bda548ae8f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/NotificationsStatusDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.notifications.types; import java.util.ArrayList; @@ -29,6 +28,7 @@ import java.util.UUID; * @since June 29, 2017 */ public class NotificationsStatusDto { + private List<NotificationEntityDto> notifications; private List<UUID> newEntries = new ArrayList<>(); private UUID lastScanned; @@ -42,8 +42,7 @@ public class NotificationsStatusDto { return notifications; } - public void setNotifications( - List<NotificationEntityDto> notifications) { + public void setNotifications(List<NotificationEntityDto> notifications) { this.notifications = notifications; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java index 9e985726dc..2a81555f9b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/notifications-rest/notifications-rest-types/src/main/java/org/openecomp/sdcrests/notifications/types/UpdateNotificationResponseStatus.java @@ -17,24 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.notifications.types; -import org.openecomp.sdc.datatypes.error.ErrorLevel; -import org.openecomp.sdc.datatypes.error.ErrorMessage; +import static org.openecomp.sdcrests.notifications.types.NotificationResponseStatus.Failure; +import static org.openecomp.sdcrests.notifications.types.NotificationResponseStatus.Success; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - -import static org.openecomp.sdcrests.notifications.types.NotificationResponseStatus.Failure; -import static org.openecomp.sdcrests.notifications.types.NotificationResponseStatus.Success; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.datatypes.error.ErrorMessage; /** * Created by TALIO on 4/27/2016. */ public class UpdateNotificationResponseStatus { + private Map<String, List<ErrorMessage>> errors = new HashMap<>(); private NotificationResponseStatus status = Success; @@ -55,8 +54,7 @@ public class UpdateNotificationResponseStatus { } public void addStructureError(String notificationId, ErrorMessage errorMessage) { - List<ErrorMessage> errorList = - errors.computeIfAbsent(notificationId, k -> new ArrayList<>()); + List<ErrorMessage> errorList = errors.computeIfAbsent(notificationId, k -> new ArrayList<>()); errorList.add(errorMessage); if (ErrorLevel.ERROR.equals(errorMessage.getLevel())) { status = Failure; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/configuration/CookieConfig.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/configuration/CookieConfig.java index c299805d0c..aeea6de894 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/configuration/CookieConfig.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/configuration/CookieConfig.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.server.configuration; import java.util.List; @@ -25,8 +24,8 @@ import java.util.List; public class CookieConfig { String securityKey = ""; - long maxSessionTimeOut = 600L*1000L; - long sessionIdleTimeOut = 30L*1000L; + long maxSessionTimeOut = 600L * 1000L; + long sessionIdleTimeOut = 30L * 1000L; String cookieName = "AuthenticationCookie"; String redirectURL = "portal_url"; List<String> excludedUrls; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java index 272e1e0e86..89d5346907 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthenticationFilter.java @@ -12,98 +12,92 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. -*/ - + */ package org.openecomp.server.filters; -import org.openecomp.sdc.logging.api.Logger; -import org.openecomp.sdc.logging.api.LoggerFactory; - -import javax.servlet.*; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.security.Principal; import java.util.Base64; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import javax.servlet.http.HttpServletResponse; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; public class ActionAuthenticationFilter implements Filter { - private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName()); - private boolean runningOnLocal = true; - - @Override - public void destroy() { - // TODO Auto-generated method stub + private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName()); + private boolean runningOnLocal = true; - } - - @Override - public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) - throws IOException, ServletException { - if (runningOnLocal) { - - HttpServletRequest httpRequest = (HttpServletRequest) arg0; - String authorizationHeader = httpRequest.getHeader("Authorization"); - if (authorizationHeader != null && !authorizationHeader.isEmpty()) { - String username; - try { - String base64Credentials = - httpRequest.getHeader("Authorization").replace("Basic", "").trim(); - String decodedCredentials = new String(Base64.getDecoder().decode(base64Credentials)); - username = decodedCredentials.substring(0, decodedCredentials.indexOf(":")); - } catch (Exception exception) { - log.error("Failed to decode credentials", exception); - setResponseStatus((HttpServletResponse) arg1, HttpServletResponse.SC_FORBIDDEN); - return; - } - if (username.startsWith("AUTH")) { - HttpServletRequestWrapper servletRequest = new HttpServletRequestWrapper(httpRequest) { - @Override - public java.lang.String getRemoteUser() { - return getUserPrincipal().getName(); - } - - @Override - public Principal getUserPrincipal() { - return () -> username.substring(0, username.indexOf("-")); - } + @Override + public void destroy() { + // TODO Auto-generated method stub + } - @Override - public boolean isUserInRole(String role) { - try { - ActionLibraryPrivilege requiredPrivilege = - ActionLibraryPrivilege.getPrivilege(httpRequest.getMethod()); - ActionLibraryPrivilege userPrivilege = ActionLibraryPrivilege - .valueOf(username.substring(username.indexOf("-") + 1).toUpperCase()); - return userPrivilege.ordinal() >= requiredPrivilege.ordinal(); - } catch (Exception exception) { - log.error("Failed to validate UserInRole", exception); - return false; - } + @Override + public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException { + if (runningOnLocal) { + HttpServletRequest httpRequest = (HttpServletRequest) arg0; + String authorizationHeader = httpRequest.getHeader("Authorization"); + if (authorizationHeader != null && !authorizationHeader.isEmpty()) { + String username; + try { + String base64Credentials = httpRequest.getHeader("Authorization").replace("Basic", "").trim(); + String decodedCredentials = new String(Base64.getDecoder().decode(base64Credentials)); + username = decodedCredentials.substring(0, decodedCredentials.indexOf(":")); + } catch (Exception exception) { + log.error("Failed to decode credentials", exception); + setResponseStatus((HttpServletResponse) arg1, HttpServletResponse.SC_FORBIDDEN); + return; + } + if (username.startsWith("AUTH")) { + HttpServletRequestWrapper servletRequest = new HttpServletRequestWrapper(httpRequest) { + @Override + public java.lang.String getRemoteUser() { + return getUserPrincipal().getName(); + } + + @Override + public Principal getUserPrincipal() { + return () -> username.substring(0, username.indexOf("-")); + } + + @Override + public boolean isUserInRole(String role) { + try { + ActionLibraryPrivilege requiredPrivilege = ActionLibraryPrivilege.getPrivilege(httpRequest.getMethod()); + ActionLibraryPrivilege userPrivilege = ActionLibraryPrivilege + .valueOf(username.substring(username.indexOf("-") + 1).toUpperCase()); + return userPrivilege.ordinal() >= requiredPrivilege.ordinal(); + } catch (Exception exception) { + log.error("Failed to validate UserInRole", exception); + return false; + } + } + }; + arg2.doFilter(servletRequest, arg1); + } else { + setResponseStatus((HttpServletResponse) arg1, HttpServletResponse.SC_FORBIDDEN); + } + } else { + setResponseStatus((HttpServletResponse) arg1, HttpServletResponse.SC_UNAUTHORIZED); } - }; - arg2.doFilter(servletRequest, arg1); } else { - setResponseStatus((HttpServletResponse) arg1, HttpServletResponse.SC_FORBIDDEN); + //call super doFilter of cadi authentication filter } - } else { - setResponseStatus((HttpServletResponse) arg1, HttpServletResponse.SC_UNAUTHORIZED); - } - } else { - //call super doFilter of cadi authentication filter } + private void setResponseStatus(HttpServletResponse response, int status) { + response.setStatus(status); + } - } - - private void setResponseStatus(HttpServletResponse response, int status) { - response.setStatus(status); - } - - @Override - public void init(FilterConfig arg0) throws ServletException { - - } - + @Override + public void init(FilterConfig arg0) throws ServletException { + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java index 10fd7d23f5..c394c3cf46 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionAuthorizationFilter.java @@ -13,43 +13,42 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.server.filters; -import javax.servlet.*; +import java.io.IOException; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.IOException; public class ActionAuthorizationFilter implements Filter { - - @Override - public void destroy() { - //destroy() is not implemented for ActionAuthorizationFilter - - } - - @Override - public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, - FilterChain filterChain) - throws IOException, ServletException { - - HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; - if (httpRequest.isUserInRole(httpRequest.getMethod().toUpperCase())) { - filterChain.doFilter(servletRequest, servletResponse); - } else { - setResponseStatus((HttpServletResponse) servletResponse, HttpServletResponse.SC_FORBIDDEN); + @Override + public void destroy() { + //destroy() is not implemented for ActionAuthorizationFilter } - } - private void setResponseStatus(HttpServletResponse response, int status) { - response.setStatus(status); - } + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) + throws IOException, ServletException { + HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; + if (httpRequest.isUserInRole(httpRequest.getMethod().toUpperCase())) { + filterChain.doFilter(servletRequest, servletResponse); + } else { + setResponseStatus((HttpServletResponse) servletResponse, HttpServletResponse.SC_FORBIDDEN); + } + } - @Override - public void init(FilterConfig arg0) throws ServletException { - //init() is not implemented for ActionAuthorizationFilter - } + private void setResponseStatus(HttpServletResponse response, int status) { + response.setStatus(status); + } + @Override + public void init(FilterConfig arg0) throws ServletException { + //init() is not implemented for ActionAuthorizationFilter + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionLibraryPrivilege.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionLibraryPrivilege.java index 6c8b1e8ca5..bd0f219f22 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionLibraryPrivilege.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/ActionLibraryPrivilege.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,59 +17,54 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.server.filters; /** * The enum Action library privilege. */ public enum ActionLibraryPrivilege { + /** + * Retrieve action library privilege. + */ + RETRIEVE, + /** + * Create action library privilege. + */ + CREATE, + /** + * Update action library privilege. + */ + UPDATE, + /** + * Delete action library privilege. + */ + DELETE; - /** - * Retrieve action library privilege. - */ - RETRIEVE, /** - * Create action library privilege. - */ - CREATE, /** - * Update action library privilege. - */ - UPDATE, /** - * Delete action library privilege. - */ - DELETE; - - /** - * Gets privilege. - * - * @param operation the operation - * @return the privilege - */ - public static ActionLibraryPrivilege getPrivilege(String operation) { - - ActionLibraryPrivilege toReturn; - - switch (operation) { - - case "GET": - toReturn = RETRIEVE; - break; - case "POST": - toReturn = CREATE; - break; - case "PUT": - toReturn = UPDATE; - break; - case "DELETE": - toReturn = DELETE; - break; - default: - toReturn = null; - break; - + /** + * Gets privilege. + * + * @param operation the operation + * @return the privilege + */ + public static ActionLibraryPrivilege getPrivilege(String operation) { + ActionLibraryPrivilege toReturn; + switch (operation) { + case "GET": + toReturn = RETRIEVE; + break; + case "POST": + toReturn = CREATE; + break; + case "PUT": + toReturn = UPDATE; + break; + case "DELETE": + toReturn = DELETE; + break; + default: + toReturn = null; + break; + } + return toReturn; } - - return toReturn; - - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/BasicAuthenticationFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/BasicAuthenticationFilter.java index 0cda5f8a27..2c2b36717a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/BasicAuthenticationFilter.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/BasicAuthenticationFilter.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,13 +17,14 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.server.filters; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.FileInputStream; +import java.io.IOException; import java.io.InputStream; import java.util.Arrays; +import java.util.Base64; import java.util.List; import java.util.Map; import java.util.Objects; @@ -33,101 +34,89 @@ import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import javax.servlet.http.HttpServletResponse; import org.onap.sdc.tosca.services.YamlUtil; import org.openecomp.sdc.be.config.Configuration.BasicAuthConfig; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Base64; import org.openecomp.sdcrests.item.rest.services.catalog.notification.EntryNotConfiguredException; public class BasicAuthenticationFilter implements Filter { - private static final Logger log = LoggerFactory.getLogger(BasicAuthenticationFilter.class); - private static final String CONFIG_FILE_PROPERTY = "configuration.yaml"; - private static final String CONFIG_SECTION = "basicAuth"; - - @Override - public void destroy() { - // TODO Auto-generated method stub - - } - - @Override - public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) - throws IOException, ServletException { - String file = Objects.requireNonNull(System.getProperty(CONFIG_FILE_PROPERTY), - "Config file location must be specified via system property " + CONFIG_FILE_PROPERTY); - Object config = getAuthenticationConfiguration(file); - ObjectMapper mapper = new ObjectMapper(); - BasicAuthConfig basicAuthConfig = mapper.convertValue(config, BasicAuthConfig.class); - HttpServletRequest httpRequest = (HttpServletRequest) arg0; - HttpServletRequestWrapper servletRequest = new HttpServletRequestWrapper(httpRequest); - - // BasicAuth is disabled - if (!basicAuthConfig.isEnabled()) { - arg2.doFilter(servletRequest, arg1); - return; - } - - List<String> excludedUrls = Arrays.asList(basicAuthConfig.getExcludedUrls().split(",")); - if (excludedUrls.contains(httpRequest.getServletPath() + httpRequest.getPathInfo())) { - // this url is included in the excludeUrls list, no need for authentication - arg2.doFilter(servletRequest, arg1); - return; - } - - - // Get the basicAuth info from the header - String authorizationHeader = httpRequest.getHeader("Authorization"); - if (authorizationHeader == null || authorizationHeader.isEmpty()) { - ((HttpServletResponse) arg1).setStatus(HttpServletResponse.SC_UNAUTHORIZED); - return; - } - - String base64Credentials = - httpRequest.getHeader("Authorization").replace("Basic", "").trim(); - if (verifyCredentials(basicAuthConfig, base64Credentials)) { - arg2.doFilter(servletRequest, arg1); - } else { - ((HttpServletResponse) arg1).setStatus(HttpServletResponse.SC_UNAUTHORIZED); - } - } + private static final Logger log = LoggerFactory.getLogger(BasicAuthenticationFilter.class); + private static final String CONFIG_FILE_PROPERTY = "configuration.yaml"; + private static final String CONFIG_SECTION = "basicAuth"; + + private static Object getAuthenticationConfiguration(String file) throws IOException { + InputStream fileInput = new FileInputStream(file); + YamlUtil yamlUtil = new YamlUtil(); + Map<?, ?> configuration = Objects.requireNonNull(yamlUtil.yamlToMap(fileInput), "Configuration cannot be empty"); + Object authenticationConfig = configuration.get(CONFIG_SECTION); + if (authenticationConfig == null) { + throw new EntryNotConfiguredException(CONFIG_SECTION + " section"); + } + return authenticationConfig; + } - @Override - public void init(FilterConfig config) throws ServletException { - } + @Override + public void destroy() { + // TODO Auto-generated method stub + } - private static Object getAuthenticationConfiguration(String file) throws IOException { - InputStream fileInput = new FileInputStream(file); - YamlUtil yamlUtil = new YamlUtil(); + @Override + public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException { + String file = Objects.requireNonNull(System.getProperty(CONFIG_FILE_PROPERTY), + "Config file location must be specified via system property " + CONFIG_FILE_PROPERTY); + Object config = getAuthenticationConfiguration(file); + ObjectMapper mapper = new ObjectMapper(); + BasicAuthConfig basicAuthConfig = mapper.convertValue(config, BasicAuthConfig.class); + HttpServletRequest httpRequest = (HttpServletRequest) arg0; + HttpServletRequestWrapper servletRequest = new HttpServletRequestWrapper(httpRequest); + // BasicAuth is disabled + if (!basicAuthConfig.isEnabled()) { + arg2.doFilter(servletRequest, arg1); + return; + } + List<String> excludedUrls = Arrays.asList(basicAuthConfig.getExcludedUrls().split(",")); + if (excludedUrls.contains(httpRequest.getServletPath() + httpRequest.getPathInfo())) { + // this url is included in the excludeUrls list, no need for authentication + arg2.doFilter(servletRequest, arg1); + return; + } + // Get the basicAuth info from the header + String authorizationHeader = httpRequest.getHeader("Authorization"); + if (authorizationHeader == null || authorizationHeader.isEmpty()) { + ((HttpServletResponse) arg1).setStatus(HttpServletResponse.SC_UNAUTHORIZED); + return; + } + String base64Credentials = httpRequest.getHeader("Authorization").replace("Basic", "").trim(); + if (verifyCredentials(basicAuthConfig, base64Credentials)) { + arg2.doFilter(servletRequest, arg1); + } else { + ((HttpServletResponse) arg1).setStatus(HttpServletResponse.SC_UNAUTHORIZED); + } + } - Map<?, ?> configuration = Objects.requireNonNull(yamlUtil.yamlToMap(fileInput), "Configuration cannot be empty"); - Object authenticationConfig = configuration.get(CONFIG_SECTION); - if (authenticationConfig == null) { - throw new EntryNotConfiguredException(CONFIG_SECTION + " section"); + @Override + public void init(FilterConfig config) throws ServletException { } - return authenticationConfig; - } - private boolean verifyCredentials (BasicAuthConfig basicAuthConfig, String credential) { - String decodedCredentials = new String(Base64.getDecoder().decode(credential)); - int p = decodedCredentials.indexOf(':'); - if (p != -1) { - String userName = decodedCredentials.substring(0, p).trim(); - String password = decodedCredentials.substring(p + 1).trim(); - if (!userName.equals(basicAuthConfig.getUserName()) || !password.equals(basicAuthConfig.getUserPass())) { - log.error("Authentication failed. Invalid user name or password"); - return false; - } - return true; - } else { - log.error("Failed to decode credentials"); - return false; + private boolean verifyCredentials(BasicAuthConfig basicAuthConfig, String credential) { + String decodedCredentials = new String(Base64.getDecoder().decode(credential)); + int p = decodedCredentials.indexOf(':'); + if (p != -1) { + String userName = decodedCredentials.substring(0, p).trim(); + String password = decodedCredentials.substring(p + 1).trim(); + if (!userName.equals(basicAuthConfig.getUserName()) || !password.equals(basicAuthConfig.getUserPass())) { + log.error("Authentication failed. Invalid user name or password"); + return false; + } + return true; + } else { + log.error("Failed to decode credentials"); + return false; + } } - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/OnboardingSessionContextFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/OnboardingSessionContextFilter.java index 5465677b5a..d8c8eb6cc4 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/OnboardingSessionContextFilter.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/OnboardingSessionContextFilter.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,25 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.server.filters; -import org.openecomp.sdcrests.filters.SessionContextFilter; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; import javax.servlet.ServletRequest; import javax.servlet.http.HttpServletRequest; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import org.openecomp.sdcrests.filters.SessionContextFilter; public class OnboardingSessionContextFilter extends SessionContextFilter { - @Override - public String getUser(ServletRequest servletRequest) { - return ((HttpServletRequest) servletRequest).getHeader(USER_ID_HEADER_PARAM); - } + @Override + public String getUser(ServletRequest servletRequest) { + return ((HttpServletRequest) servletRequest).getHeader(USER_ID_HEADER_PARAM); + } - @Override - public String getTenant(ServletRequest servletRequest) { - return "dox"; - } + @Override + public String getTenant(ServletRequest servletRequest) { + return "dox"; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/RestrictionAccessFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/RestrictionAccessFilter.java index 61a74500ca..19b5e52cf8 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/RestrictionAccessFilter.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/filters/RestrictionAccessFilter.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,25 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.server.filters; import com.fasterxml.jackson.databind.ObjectMapper; -import org.onap.sdc.tosca.services.YamlUtil; -import org.openecomp.sdc.securityutil.ISessionValidationFilterConfiguration; -import org.openecomp.sdc.securityutil.filters.SessionValidationFilter; -import org.openecomp.server.configuration.CookieConfig; -import org.openecomp.sdc.logging.api.Logger; -import org.openecomp.sdc.logging.api.LoggerFactory; -import org.openecomp.sdcrests.item.rest.services.catalog.notification.EntryNotConfiguredException; - -import javax.servlet.http.Cookie; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.List; import java.util.Map; import java.util.Objects; +import javax.servlet.http.Cookie; +import org.onap.sdc.tosca.services.YamlUtil; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.securityutil.ISessionValidationFilterConfiguration; +import org.openecomp.sdc.securityutil.filters.SessionValidationFilter; +import org.openecomp.sdcrests.item.rest.services.catalog.notification.EntryNotConfiguredException; +import org.openecomp.server.configuration.CookieConfig; public class RestrictionAccessFilter extends SessionValidationFilter { @@ -43,7 +41,23 @@ public class RestrictionAccessFilter extends SessionValidationFilter { private static final String CONFIG_FILE_PROPERTY = "configuration.yaml"; private static final String CONFIG_SECTION = "authCookie"; + @Override + public ISessionValidationFilterConfiguration getFilterConfiguration() { + return Configuration.getInstance(); + } + + @Override + protected Cookie addRoleToCookie(Cookie cookie) { + return cookie; + } + + @Override + protected boolean isRoleValid(Cookie cookie) { + return true; + } + private static class Configuration implements ISessionValidationFilterConfiguration { + private static Configuration instance; private String securityKey; private long maxSessionTimeOut; @@ -55,13 +69,10 @@ public class RestrictionAccessFilter extends SessionValidationFilter { private String cookiePath; private boolean isCookieHttpOnly; - private Configuration() { try { - String file = Objects.requireNonNull(System.getProperty(CONFIG_FILE_PROPERTY), - "Config file location must be specified via system property " + CONFIG_FILE_PROPERTY); - + "Config file location must be specified via system property " + CONFIG_FILE_PROPERTY); Object config = getAuthenticationConfiguration(file); ObjectMapper mapper = new ObjectMapper(); CookieConfig cookieConfig = mapper.convertValue(config, CookieConfig.class); @@ -74,11 +85,9 @@ public class RestrictionAccessFilter extends SessionValidationFilter { this.cookieDomain = cookieConfig.getDomain(); this.cookiePath = cookieConfig.getPath(); this.isCookieHttpOnly = cookieConfig.isHttpOnly(); - } catch (Exception e) { LOGGER.warn("Failed to load configuration. ", e); } - } public static Configuration getInstance() { @@ -89,18 +98,15 @@ public class RestrictionAccessFilter extends SessionValidationFilter { } private static Object getAuthenticationConfiguration(String file) throws IOException { - Map<?, ?> configuration = Objects.requireNonNull(readConfigurationFile(file), "Configuration cannot be empty"); Object authenticationConfig = configuration.get(CONFIG_SECTION); if (authenticationConfig == null) { throw new EntryNotConfiguredException(CONFIG_SECTION + " section"); } - return authenticationConfig; } private static Map<?, ?> readConfigurationFile(String file) throws IOException { - try (InputStream fileInput = new FileInputStream(file)) { YamlUtil yamlUtil = new YamlUtil(); return yamlUtil.yamlToMap(fileInput); @@ -152,19 +158,4 @@ public class RestrictionAccessFilter extends SessionValidationFilter { return excludedUrls; } } - - @Override - public ISessionValidationFilterConfiguration getFilterConfiguration() { - return Configuration.getInstance(); - } - - @Override - protected Cookie addRoleToCookie(Cookie cookie) { - return cookie; - } - - @Override - protected boolean isRoleValid(Cookie cookie) { - return true; - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/DefaultOutput.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/DefaultOutput.java index 16110816b2..076582f5d5 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/DefaultOutput.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/DefaultOutput.java @@ -15,159 +15,165 @@ */ package org.openecomp.server.interceptors; - -import javax.ws.rs.core.*; import java.lang.annotation.Annotation; import java.net.URI; -import java.util.*; +import java.util.Collections; +import java.util.Date; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import javax.ws.rs.core.EntityTag; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.Link; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.NewCookie; +import javax.ws.rs.core.Response; public class DefaultOutput extends Response { - private static final long serialVersionUID = 8061802931931401706L; - - private final int status; - private final Object entity; - private MultivaluedMap<String, Object> metadata; - - public DefaultOutput(int s0, Object e0) { - this.status = s0; - this.entity = e0; - } - - @Override - public Object getEntity() { - return entity; - } - - @Override - public <T> T readEntity(Class<T> asClass) { - return null; - } - - @Override - public <T> T readEntity(GenericType<T> genericType) { - return null; - } - - @Override - public <T> T readEntity(Class<T> asClass, Annotation[] annotations) { - return null; - } - - @Override - public <T> T readEntity(GenericType<T> var1, Annotation[] var2) { - return null; - } - - @Override - public boolean hasEntity() { - return false; - } - - @Override - public boolean bufferEntity() { - return false; - } - - @Override - public void close() { - //close() is not implemented for DefaultOutput - } - - @Override - public MediaType getMediaType() { - return null; - } - - @Override - public Locale getLanguage() { - return null; - } - - @Override - public int getLength() { - return 0; - } - - @Override - public Set<String> getAllowedMethods() { - return Collections.emptySet(); - } - - @Override - public Map<String, NewCookie> getCookies() { - return null; - } - - @Override - public EntityTag getEntityTag() { - return null; - } - - @Override - public Date getDate() { - return null; - } - - @Override - public Date getLastModified() { - return null; - } - - @Override - public URI getLocation() { - return null; - } - - @Override - public Set<Link> getLinks() { - return Collections.emptySet(); - } - - @Override - public boolean hasLink(String s0) { - return false; - } - - - @Override - public Link getLink(String s0) { - return null; - } - - @Override - public Link.Builder getLinkBuilder(String s0) { - return null; - } - - @Override - public int getStatus() { - return status; - } - - @Override - public StatusType getStatusInfo() { - return null; - } - - void addMetadata(MultivaluedMap<String, Object> meta) { - this.metadata = meta; - } - - @Override - public MultivaluedMap<String, Object> getMetadata() { - // don't worry about cloning for now - return metadata; - } - - @Override - public MultivaluedMap<String, String> getStringHeaders() { - return null; - } - - @Override - public String getHeaderString(String s0) { - return null; - } - + private static final long serialVersionUID = 8061802931931401706L; + private final int status; + private final Object entity; + private MultivaluedMap<String, Object> metadata; + + public DefaultOutput(int s0, Object e0) { + this.status = s0; + this.entity = e0; + } + + @Override + public Object getEntity() { + return entity; + } + + @Override + public <T> T readEntity(Class<T> asClass) { + return null; + } + + @Override + public <T> T readEntity(GenericType<T> genericType) { + return null; + } + + @Override + public <T> T readEntity(Class<T> asClass, Annotation[] annotations) { + return null; + } + + @Override + public <T> T readEntity(GenericType<T> var1, Annotation[] var2) { + return null; + } + + @Override + public boolean hasEntity() { + return false; + } + + @Override + public boolean bufferEntity() { + return false; + } + + @Override + public void close() { + //close() is not implemented for DefaultOutput + } + + @Override + public MediaType getMediaType() { + return null; + } + + @Override + public Locale getLanguage() { + return null; + } + + @Override + public int getLength() { + return 0; + } + + @Override + public Set<String> getAllowedMethods() { + return Collections.emptySet(); + } + + @Override + public Map<String, NewCookie> getCookies() { + return null; + } + + @Override + public EntityTag getEntityTag() { + return null; + } + + @Override + public Date getDate() { + return null; + } + + @Override + public Date getLastModified() { + return null; + } + + @Override + public URI getLocation() { + return null; + } + + @Override + public Set<Link> getLinks() { + return Collections.emptySet(); + } + + @Override + public boolean hasLink(String s0) { + return false; + } + + @Override + public Link getLink(String s0) { + return null; + } + + @Override + public Link.Builder getLinkBuilder(String s0) { + return null; + } + + @Override + public int getStatus() { + return status; + } + + @Override + public StatusType getStatusInfo() { + return null; + } + + void addMetadata(MultivaluedMap<String, Object> meta) { + this.metadata = meta; + } + + @Override + public MultivaluedMap<String, Object> getMetadata() { + // don't worry about cloning for now + return metadata; + } + + @Override + public MultivaluedMap<String, String> getStringHeaders() { + return null; + } + + @Override + public String getHeaderString(String s0) { + return null; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/EmptyOutputOutInterceptor.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/EmptyOutputOutInterceptor.java index 440354318d..b8548806fe 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/EmptyOutputOutInterceptor.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/EmptyOutputOutInterceptor.java @@ -15,48 +15,44 @@ */ package org.openecomp.server.interceptors; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor; import org.apache.cxf.message.Message; import org.apache.cxf.message.MessageContentsList; import org.apache.cxf.phase.Phase; -import javax.inject.Named; -import javax.ws.rs.core.Response; - - /** * The type Empty output out interceptor. */ @Named public class EmptyOutputOutInterceptor extends AbstractOutDatabindingInterceptor { - public EmptyOutputOutInterceptor() { - // To be executed in post logical phase before marshal phase - super(Phase.POST_LOGICAL); - } + public EmptyOutputOutInterceptor() { + // To be executed in post logical phase before marshal phase + super(Phase.POST_LOGICAL); + } - /** - * Intercepts a message. - * Interceptors should NOT invoke handleMessage or handleFault - * on the next interceptor - the interceptor chain will - * take care of this. - * - * @param message input message. - */ - @Override - public void handleMessage(Message message) { - //get the message - MessageContentsList objs = MessageContentsList.getContentsList(message); - if (objs.get(0) instanceof Response) { - //check if response is present but entity inside it is null the set a default entity - int status = ((Response) objs.get(0)).getStatus(); - Object entity = ((Response) objs.get(0)).getEntity(); - // in case of staus 200 and entity is null send InternalEmptyObject in output. - if (entity == null && status == 200) { - DefaultOutput defaultOutput = new DefaultOutput(status, new InternalEmptyObject()); - defaultOutput.addMetadata(((Response) objs.get(0)).getMetadata()); - objs.set(0, defaultOutput); - } + /** + * Intercepts a message. Interceptors should NOT invoke handleMessage or handleFault on the next interceptor - the interceptor chain will take + * care of this. + * + * @param message input message. + */ + @Override + public void handleMessage(Message message) { + //get the message + MessageContentsList objs = MessageContentsList.getContentsList(message); + if (objs.get(0) instanceof Response) { + //check if response is present but entity inside it is null the set a default entity + int status = ((Response) objs.get(0)).getStatus(); + Object entity = ((Response) objs.get(0)).getEntity(); + // in case of staus 200 and entity is null send InternalEmptyObject in output. + if (entity == null && status == 200) { + DefaultOutput defaultOutput = new DefaultOutput(status, new InternalEmptyObject()); + defaultOutput.addMetadata(((Response) objs.get(0)).getMetadata()); + objs.set(0, defaultOutput); + } + } } - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/InternalEmptyObject.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/InternalEmptyObject.java index b052c57d10..e65be6d38f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/InternalEmptyObject.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/interceptors/InternalEmptyObject.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,11 +17,9 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.server.interceptors; import com.fasterxml.jackson.annotation.JsonAutoDetect; - import java.io.Serializable; /** diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java index b1c818cabb..606a0f7f7c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/java/org/openecomp/server/listeners/OnboardingAppStartupListener.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,30 +17,26 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.server.listeners; - -import org.openecomp.sdc.common.session.SessionContextProviderFactory; -import org.springframework.web.context.ContextLoaderListener; - import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; +import org.openecomp.sdc.common.session.SessionContextProviderFactory; +import org.springframework.web.context.ContextLoaderListener; public class OnboardingAppStartupListener implements ServletContextListener { - ContextLoaderListener springListener; + ContextLoaderListener springListener; - @Override - public void contextInitialized(ServletContextEvent servletContextEvent) { - SessionContextProviderFactory.getInstance().createInterface().create("onboarding", - "dox"); - springListener = new ContextLoaderListener(); - springListener.initWebApplicationContext(servletContextEvent.getServletContext()); - } + @Override + public void contextInitialized(ServletContextEvent servletContextEvent) { + SessionContextProviderFactory.getInstance().createInterface().create("onboarding", "dox"); + springListener = new ContextLoaderListener(); + springListener.initWebApplicationContext(servletContextEvent.getServletContext()); + } - @Override - public void contextDestroyed(ServletContextEvent servletContextEvent) { - springListener.closeWebApplicationContext(servletContextEvent.getServletContext()); - } + @Override + public void contextDestroyed(ServletContextEvent servletContextEvent) { + springListener.closeWebApplicationContext(servletContextEvent.getServletContext()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java index 230d1610eb..3f7dd523f9 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/RestConstants.java @@ -13,20 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.common; public class RestConstants { - // value Should be equal to com.tlv.sdc.common.api.Constants#USER_ID_HEADER - public static final String USER_ID_HEADER_PARAM = "USER_ID"; - public static final String LAST_DELIVERED_QUERY_PARAM = "LAST_DELIVERED_EVENT_ID"; - public static final String USER_MISSING_ERROR_MSG = - "Field does not conform to predefined criteria : user : may not be null"; - - public static final String INVALID_JSON_ERROR_MESSAGE = - "Field does not conform to predefined criteria : body :must be in JSON format"; - private RestConstants() { + // value Should be equal to com.tlv.sdc.common.api.Constants#USER_ID_HEADER + public static final String USER_ID_HEADER_PARAM = "USER_ID"; + public static final String LAST_DELIVERED_QUERY_PARAM = "LAST_DELIVERED_EVENT_ID"; + public static final String USER_MISSING_ERROR_MSG = "Field does not conform to predefined criteria : user : may not be null"; + public static final String INVALID_JSON_ERROR_MESSAGE = "Field does not conform to predefined criteria : body :must be in JSON format"; - } + private RestConstants() { + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorCodeToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorCodeToDto.java index cad5c69899..558d2e7c22 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorCodeToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorCodeToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.common.mapping; import org.openecomp.sdc.common.errors.ErrorCode; @@ -25,10 +24,11 @@ import org.openecomp.sdcrests.common.types.ErrorCodeDto; import org.openecomp.sdcrests.mapping.MappingBase; public class MapErrorCodeToDto extends MappingBase<ErrorCode, ErrorCodeDto> { - @Override - public void doMapping(ErrorCode source, ErrorCodeDto target) { - target.setId(source.id()); - target.setCategory(source.category()); - target.setMessage(source.message()); - } + + @Override + public void doMapping(ErrorCode source, ErrorCodeDto target) { + target.setId(source.id()); + target.setCategory(source.category()); + target.setMessage(source.message()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorMessageToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorMessageToDto.java index 83c7b15980..78262b8c30 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorMessageToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/mapping/MapErrorMessageToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.common.mapping; import org.openecomp.sdc.datatypes.error.ErrorMessage; @@ -25,9 +24,10 @@ import org.openecomp.sdcrests.common.types.ErrorMessageDto; import org.openecomp.sdcrests.mapping.MappingBase; public class MapErrorMessageToDto extends MappingBase<ErrorMessage, ErrorMessageDto> { - @Override - public void doMapping(ErrorMessage source, ErrorMessageDto target) { - target.setMessage(source.getMessage()); - target.setLevel(source.getLevel()); - } + + @Override + public void doMapping(ErrorMessage source, ErrorMessageDto target) { + target.setMessage(source.getMessage()); + target.setLevel(source.getLevel()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorCodeDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorCodeDto.java index 3615f89afc..f70d863653 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorCodeDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorCodeDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,37 +17,37 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.common.types; import org.openecomp.sdc.common.errors.ErrorCategory; public class ErrorCodeDto { - private String id; - private String message; - private ErrorCategory category; - public String getId() { - return id; - } + private String id; + private String message; + private ErrorCategory category; + + public String getId() { + return id; + } - public void setId(String id) { - this.id = id; - } + public void setId(String id) { + this.id = id; + } - public String getMessage() { - return message; - } + public String getMessage() { + return message; + } - public void setMessage(String message) { - this.message = message; - } + public void setMessage(String message) { + this.message = message; + } - public ErrorCategory getCategory() { - return category; - } + public ErrorCategory getCategory() { + return category; + } - public void setCategory(ErrorCategory category) { - this.category = category; - } + public void setCategory(ErrorCategory category) { + this.category = category; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorMessageDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorMessageDto.java index f63a9b0ced..9bac491ed1 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorMessageDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/ErrorMessageDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,28 +17,28 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.common.types; import org.openecomp.sdc.datatypes.error.ErrorLevel; public class ErrorMessageDto { - private ErrorLevel level; - private String message; - public ErrorLevel getLevel() { - return level; - } + private ErrorLevel level; + private String message; + + public ErrorLevel getLevel() { + return level; + } - public void setLevel(ErrorLevel level) { - this.level = level; - } + public void setLevel(ErrorLevel level) { + this.level = level; + } - public String getMessage() { - return message; - } + public String getMessage() { + return message; + } - public void setMessage(String message) { - this.message = message; - } + public void setMessage(String message) { + this.message = message; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java index 9fe70fc5e5..0546180575 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/DefaultExceptionMapper.java @@ -13,23 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.errors; +import com.fasterxml.jackson.databind.JsonMappingException; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; - import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import javax.validation.Path; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; - import org.apache.commons.collections4.CollectionUtils; -import com.fasterxml.jackson.databind.JsonMappingException; import org.hibernate.validator.internal.engine.path.PathImpl; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.utilities.json.JsonUtil; @@ -47,9 +44,8 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> { private static final String ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE = "errorCodesToResponseStatusMapping.json"; @SuppressWarnings("unchecked") - private static final Map<String, String> ERROR_CODE_TO_RESPONSE_STATUS = FileUtils.readViaInputStream( - ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE, stream -> JsonUtil.json2Object(stream, Map.class)); - + private static final Map<String, String> ERROR_CODE_TO_RESPONSE_STATUS = FileUtils + .readViaInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE, stream -> JsonUtil.json2Object(stream, Map.class)); private static final Logger LOGGER = LoggerFactory.getLogger(DefaultExceptionMapper.class); @Override @@ -59,14 +55,11 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> { response = transform(CoreException.class.cast(exception)); } else if (exception instanceof ConstraintViolationException) { response = transform(ConstraintViolationException.class.cast(exception)); - } else if (exception instanceof JsonMappingException) { response = transform(JsonMappingException.class.cast(exception)); - } else { response = transform(exception); } - List<Object> contentTypes = new ArrayList<>(); contentTypes.add(MediaType.APPLICATION_JSON); response.getMetadata().put("Content-Type", contentTypes); @@ -77,32 +70,23 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> { Response response; ErrorCode code = coreException.code(); LOGGER.error(code.message(), coreException); - if (coreException.code().category().equals(ErrorCategory.APPLICATION)) { if (Response.Status.NOT_FOUND.name().equals(ERROR_CODE_TO_RESPONSE_STATUS.get(code.id()))) { - response = Response.status(Response.Status.NOT_FOUND).entity(toEntity(Response.Status.NOT_FOUND, code)) - .build(); + response = Response.status(Response.Status.NOT_FOUND).entity(toEntity(Response.Status.NOT_FOUND, code)).build(); } else if (Response.Status.BAD_REQUEST.name().equals(ERROR_CODE_TO_RESPONSE_STATUS.get(code.id()))) { - response = - Response.status(Response.Status.BAD_REQUEST).entity(toEntity(Response.Status.BAD_REQUEST, code)) - .build(); + response = Response.status(Response.Status.BAD_REQUEST).entity(toEntity(Response.Status.BAD_REQUEST, code)).build(); } else { - response = Response.status(Response.Status.EXPECTATION_FAILED) - .entity(toEntity(Response.Status.EXPECTATION_FAILED, code)).build(); + response = Response.status(Response.Status.EXPECTATION_FAILED).entity(toEntity(Response.Status.EXPECTATION_FAILED, code)).build(); } } else { - response = Response.status(Response.Status.INTERNAL_SERVER_ERROR) - .entity(toEntity(Response.Status.INTERNAL_SERVER_ERROR, code)).build(); + response = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(toEntity(Response.Status.INTERNAL_SERVER_ERROR, code)).build(); } - - return response; } private Response transform(ConstraintViolationException validationException) { Set<ConstraintViolation<?>> constraintViolationSet = validationException.getConstraintViolations(); String message; - String fieldName = null; if (CollectionUtils.isEmpty(constraintViolationSet)) { message = validationException.getMessage(); @@ -111,28 +95,24 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> { ConstraintViolation<?> constraintViolation = constraintViolationSet.iterator().next(); message = constraintViolation.getMessage(); fieldName = getFieldName(constraintViolation.getPropertyPath()); - } - ErrorCode validationErrorCode = new ValidationErrorBuilder(message, fieldName).build(); - LOGGER.error(validationErrorCode.message(), validationException); return Response.status(Response.Status.EXPECTATION_FAILED) //error 417 - .entity(toEntity(Response.Status.EXPECTATION_FAILED, validationErrorCode)).build(); + .entity(toEntity(Response.Status.EXPECTATION_FAILED, validationErrorCode)).build(); } private Response transform(JsonMappingException jsonMappingException) { ErrorCode jsonMappingErrorCode = new JsonMappingErrorBuilder().build(); LOGGER.error(jsonMappingErrorCode.message(), jsonMappingException); return Response.status(Response.Status.EXPECTATION_FAILED) //error 417 - .entity(toEntity(Response.Status.EXPECTATION_FAILED, jsonMappingErrorCode)).build(); + .entity(toEntity(Response.Status.EXPECTATION_FAILED, jsonMappingErrorCode)).build(); } private Response transform(Exception exception) { ErrorCode errorCode = new GeneralErrorBuilder().build(); LOGGER.error(errorCode.message(), exception); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR) - .entity(toEntity(Response.Status.INTERNAL_SERVER_ERROR, errorCode)).build(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(toEntity(Response.Status.INTERNAL_SERVER_ERROR, errorCode)).build(); } private String getFieldName(Path propertyPath) { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/ZusammenExceptionMapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/ZusammenExceptionMapper.java index abf6024701..497d3cfeb7 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/ZusammenExceptionMapper.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/errors/ZusammenExceptionMapper.java @@ -13,16 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.errors; import com.amdocs.zusammen.datatypes.response.Module; - import java.util.stream.Stream; - import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; - import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.common.errors.ErrorCodeAndMessage; import org.openecomp.sdc.common.errors.GeneralErrorBuilder; @@ -32,19 +28,16 @@ import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; public class ZusammenExceptionMapper implements ExceptionMapper<SdcRuntimeException> { + private static final String ZUSAMMEN_DB_PREFIX = Module.ZDB + "-"; static final String VLM_VSP_VERSION_ID_DOES_NOT_EXISTS = - ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ITEM_VERSION_NOT_EXIST; + ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ITEM_VERSION_NOT_EXIST; static final String VLM_VSP_ITEM_ID_DOES_NOT_EXISTS = - ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ITEM_DOES_NOT_EXIST; - static final String SUB_ENTITY_ID_DOES_NOT_EXISTS = - ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ELEMENT_GET_INFO; - static final String FAILED_TO_SYNC = - ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ITEM_VERSION_SYNC; + ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ITEM_DOES_NOT_EXIST; + static final String SUB_ENTITY_ID_DOES_NOT_EXISTS = ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ELEMENT_GET_INFO; + static final String FAILED_TO_SYNC = ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ITEM_VERSION_SYNC; static final String FAILED_TO_PUBLISH_OUT_OF_SYNC = - ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode - .ZU_ITEM_VERSION_PUBLISH_NOT_ALLOWED; - + ZUSAMMEN_DB_PREFIX + com.amdocs.zusammen.datatypes.response.ErrorCode.ZU_ITEM_VERSION_PUBLISH_NOT_ALLOWED; private static final Logger LOGGER = LoggerFactory.getLogger(ZusammenExceptionMapper.class); @Override @@ -53,29 +46,24 @@ public class ZusammenExceptionMapper implements ExceptionMapper<SdcRuntimeExcept } private Response transform(SdcRuntimeException exception) { - if (Stream.of(VLM_VSP_ITEM_ID_DOES_NOT_EXISTS, VLM_VSP_VERSION_ID_DOES_NOT_EXISTS) - .anyMatch(exception.getMessage()::contains)) { + if (Stream.of(VLM_VSP_ITEM_ID_DOES_NOT_EXISTS, VLM_VSP_VERSION_ID_DOES_NOT_EXISTS).anyMatch(exception.getMessage()::contains)) { return generateSdcErrorResponse(Messages.ENTITY_NOT_FOUND, Response.Status.NOT_FOUND, - new SdcRuntimeException(Messages.ENTITY_NOT_FOUND.getErrorMessage(), exception)); + new SdcRuntimeException(Messages.ENTITY_NOT_FOUND.getErrorMessage(), exception)); } else if (exception.getMessage().contains(SUB_ENTITY_ID_DOES_NOT_EXISTS)) { return generateSdcErrorResponse(Messages.SUB_ENTITY_NOT_FOUND, Response.Status.NOT_FOUND, - new SdcRuntimeException(Messages.SUB_ENTITY_NOT_FOUND.getErrorMessage(), exception)); + new SdcRuntimeException(Messages.SUB_ENTITY_NOT_FOUND.getErrorMessage(), exception)); } else if (exception.getMessage().contains(FAILED_TO_SYNC)) { return generateSdcErrorResponse(Messages.FAILED_TO_SYNC, Response.Status.EXPECTATION_FAILED, - new SdcRuntimeException(Messages.FAILED_TO_SYNC.getErrorMessage(), exception)); + new SdcRuntimeException(Messages.FAILED_TO_SYNC.getErrorMessage(), exception)); } else if (exception.getMessage().contains(FAILED_TO_PUBLISH_OUT_OF_SYNC)) { return generateSdcErrorResponse(Messages.FAILED_TO_PUBLISH_OUT_OF_SYNC, Response.Status.EXPECTATION_FAILED, - new SdcRuntimeException(Messages.FAILED_TO_PUBLISH_OUT_OF_SYNC.getErrorMessage(), exception)); + new SdcRuntimeException(Messages.FAILED_TO_PUBLISH_OUT_OF_SYNC.getErrorMessage(), exception)); } - return genericError(exception); } private Response generateSdcErrorResponse(Messages messages, Response.Status status, Exception exception) { - ErrorCode errorCode = new ErrorCode.ErrorCodeBuilder() - .withId(messages.name()) - .withMessage(exception.getMessage()).build(); - + ErrorCode errorCode = new ErrorCode.ErrorCodeBuilder().withId(messages.name()).withMessage(exception.getMessage()).build(); LOGGER.error(errorCode.message(), exception); return Response.status(status).entity(new ErrorCodeAndMessage(status, errorCode)).build(); } @@ -84,6 +72,6 @@ public class ZusammenExceptionMapper implements ExceptionMapper<SdcRuntimeExcept ErrorCode errorCode = new GeneralErrorBuilder().build(); LOGGER.error(errorCode.message(), exception); return Response.status(Response.Status.INTERNAL_SERVER_ERROR) - .entity(new ErrorCodeAndMessage(Response.Status.INTERNAL_SERVER_ERROR, errorCode)).build(); + .entity(new ErrorCodeAndMessage(Response.Status.INTERNAL_SERVER_ERROR, errorCode)).build(); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java index 2770d24959..3149d01b50 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/filters/SessionContextFilter.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,12 +17,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.filters; -import org.openecomp.sdc.common.session.SessionContextProvider; -import org.openecomp.sdc.common.session.SessionContextProviderFactory; - import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; @@ -31,37 +27,34 @@ import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; +import org.openecomp.sdc.common.session.SessionContextProvider; +import org.openecomp.sdc.common.session.SessionContextProviderFactory; public abstract class SessionContextFilter implements Filter { - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } - - @Override - public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, - FilterChain filterChain) throws IOException, ServletException { - SessionContextProvider contextProvider = - SessionContextProviderFactory.getInstance().createInterface(); - - try { - if (servletRequest instanceof HttpServletRequest) { - - contextProvider.create(getUser(servletRequest),getTenant(servletRequest)); - } - - filterChain.doFilter(servletRequest, servletResponse); - } finally { - contextProvider.close(); + @Override + public void init(FilterConfig filterConfig) throws ServletException { } - } - @Override - public void destroy() { + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) + throws IOException, ServletException { + SessionContextProvider contextProvider = SessionContextProviderFactory.getInstance().createInterface(); + try { + if (servletRequest instanceof HttpServletRequest) { + contextProvider.create(getUser(servletRequest), getTenant(servletRequest)); + } + filterChain.doFilter(servletRequest, servletResponse); + } finally { + contextProvider.close(); + } + } - } + @Override + public void destroy() { + } - public abstract String getUser(ServletRequest servletRequest); + public abstract String getUser(ServletRequest servletRequest); - public abstract String getTenant(ServletRequest servletRequest); + public abstract String getTenant(ServletRequest servletRequest); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java index 0d394eb9aa..688b49c6e0 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/EchoMapMapping.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.mapping; import java.util.Map; @@ -23,8 +22,8 @@ import java.util.Map; */ public class EchoMapMapping extends MappingBase<Map<String, String>, Map<String, String>> { - @Override - public void doMapping(Map<String, String> source, Map<String, String> target) { - target.putAll(source); - } + @Override + public void doMapping(Map<String, String> source, Map<String, String> target) { + target.putAll(source); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java index 8b6fca5ae1..68a16e854c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/mapping/MappingBase.java @@ -13,86 +13,71 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.mapping; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCode; /** - * Base class for all mapping classes. Mapping classes will perform data mapping from source object - * to target object Base class provides following<br> <ol> <li>provides life cycle of - * mapping class , first mapSimpleProperties is called and then mapComplexProperties is - * called.</li> <li>methods mapSimpleProperties and mapComplexProperties with default - * implementation, these should be overridden by concrete mapping classes for writing mapping - * logic.</li> </ol> - * - * + * Base class for all mapping classes. Mapping classes will perform data mapping from source object to target object Base class provides + * following<br> + * <ol> <li>provides life cycle of mapping class , first mapSimpleProperties is called and then mapComplexProperties is called.</li> <li>methods + * mapSimpleProperties and mapComplexProperties with default implementation, these should be overridden by concrete mapping classes for writing + * mapping logic.</li> </ol> */ - public abstract class MappingBase<S, T> { - /** - * Method is called for starting mapping from source object to target object method sets context - * in the thread locale and than calls mapSimpleProperties and mapComplexProperties - * respectively. - * - * @param source : source object for mapping - * @param clazz : target <code>Class</code> for mapping - * @return <code>T</code> - instance of type <code>T</code> - */ - - public final T applyMapping(final S source, Class<T> clazz) { - T target = (T) instantiateTarget(clazz); - if (source != null && target != null) { - preMapping(source, target); - doMapping(source, target); - postMapping(source, target); - + /** + * Method is called for starting mapping from source object to target object method sets context in the thread locale and than calls + * mapSimpleProperties and mapComplexProperties respectively. + * + * @param source : source object for mapping + * @param clazz : target <code>Class</code> for mapping + * @return <code>T</code> - instance of type <code>T</code> + */ + public final T applyMapping(final S source, Class<T> clazz) { + T target = (T) instantiateTarget(clazz); + if (source != null && target != null) { + preMapping(source, target); + doMapping(source, target); + postMapping(source, target); + } + return target; } - return target; - - } - /** - * This method is called before the <code>doMapping</code> method. - */ - public void preMapping(final S source, T target) { - // extension point - } - - /** - * The actual method that does the mapping between the <code>source</code> to <code>target</code> - * objects. This method is being called automatically as part of the mapper class. This - * method must be override (it is abstract) by the mapper class. - * - * @param source - the source object. - * @param target - the target object. - */ - - public abstract void doMapping(final S source, T target); - - /** - * This method is called after the <code>doMapping</code> method. - */ - public void postMapping(final S source, T target) { - // extension point - } - - /** - * Creates the instance of the input class. - * - * @return <code>Object</code> - */ + /** + * This method is called before the <code>doMapping</code> method. + */ + public void preMapping(final S source, T target) { + // extension point + } - private Object instantiateTarget(final Class<?> clazz) { + /** + * The actual method that does the mapping between the <code>source</code> to <code>target</code> objects. This method is being called + * automatically as part of the mapper class. This method must be override (it is abstract) by the mapper class. + * + * @param source - the source object. + * @param target - the target object. + */ + public abstract void doMapping(final S source, T target); + + /** + * This method is called after the <code>doMapping</code> method. + */ + public void postMapping(final S source, T target) { + // extension point + } - try { - return clazz.newInstance(); - } catch (InstantiationException | IllegalAccessException exception ) { - throw new CoreException((new ErrorCode.ErrorCodeBuilder()) - .withMessage(exception.getMessage()).build(), exception); + /** + * Creates the instance of the input class. + * + * @return <code>Object</code> + */ + private Object instantiateTarget(final Class<?> clazz) { + try { + return clazz.newInstance(); + } catch (InstantiationException | IllegalAccessException exception) { + throw new CoreException((new ErrorCode.ErrorCodeBuilder()).withMessage(exception.getMessage()).build(), exception); + } } - } } - diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java index b73d2d93c5..7bff3d5b77 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/GenericCollectionWrapper.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.wrappers; import java.io.Serializable; @@ -25,57 +24,56 @@ import java.util.ArrayList; import java.util.List; public class GenericCollectionWrapper<T> implements Serializable { - private static final long serialVersionUID = 1L; - - private transient List<T> results; - private int listCount; - public GenericCollectionWrapper() { - this.results = new ArrayList<>(); - } + private static final long serialVersionUID = 1L; + private transient List<T> results; + private int listCount; - /** - * Instantiates a new Generic collection wrapper. - * - * @param list the list - */ - public GenericCollectionWrapper(List<T> list) { - if (!list.isEmpty()) { - this.results = list; - this.listCount = list.size(); + public GenericCollectionWrapper() { + this.results = new ArrayList<>(); } - else { - this.results = new ArrayList<>(); + + /** + * Instantiates a new Generic collection wrapper. + * + * @param list the list + */ + public GenericCollectionWrapper(List<T> list) { + if (!list.isEmpty()) { + this.results = list; + this.listCount = list.size(); + } else { + this.results = new ArrayList<>(); + } } - } - public List<T> getResults() { - return results; - } + public List<T> getResults() { + return results; + } - public void setResults(List<T> results) { - this.results = results; - } + public void setResults(List<T> results) { + this.results = results; + } - public int getListCount() { - return listCount; - } + public int getListCount() { + return listCount; + } - public void setListCount(int listCount) { - this.listCount = listCount; - } + public void setListCount(int listCount) { + this.listCount = listCount; + } - /** - * Add boolean. - * - * @param item the list item - * @return the boolean - */ - public boolean add(T item) { - if (this.getResults().add(item)) { - this.setListCount(this.getResults().size()); - return true; + /** + * Add boolean. + * + * @param item the list item + * @return the boolean + */ + public boolean add(T item) { + if (this.getResults().add(item)) { + this.setListCount(this.getResults().size()); + return true; + } + return false; } - return false; - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/StringWrapperResponse.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/StringWrapperResponse.java index aad4e606de..0cfd5838f4 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/StringWrapperResponse.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/wrappers/StringWrapperResponse.java @@ -13,28 +13,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.wrappers; public class StringWrapperResponse { - private String value; - public StringWrapperResponse() { - // defualt ctor is used by reflection, for instance JSON mapping - super(); - } + private String value; - public StringWrapperResponse(String value) { - super(); - this.value = value; - } + public StringWrapperResponse() { + // defualt ctor is used by reflection, for instance JSON mapping + super(); + } - public String getValue() { - return value; - } + public StringWrapperResponse(String value) { + super(); + this.value = value; + } - public void setValue(String value) { - this.value = value; - } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/TogglzFeatures.java b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/TogglzFeatures.java index bdeefa46f2..ab010c288b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/TogglzFeatures.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/TogglzFeatures.java @@ -13,26 +13,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.togglz.rest; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdcrests.togglz.types.FeatureDto; import org.openecomp.sdcrests.togglz.types.FeatureSetDto; import org.springframework.validation.annotation.Validated; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - - @Path("/v1.0/togglz") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -40,24 +41,22 @@ import javax.ws.rs.core.Response; @Validated public interface TogglzFeatures { - @GET - @Operation(description = "Get TOGGLZ Features", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = FeatureSetDto.class))))) - Response getFeatures(); - - - @PUT - @Path("/state/{state}") - @Operation(description = "Update feature toggle state for all features") - Response setAllFeatures(@PathParam("state") boolean state); + @GET + @Operation(description = "Get TOGGLZ Features", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = FeatureSetDto.class))))) + Response getFeatures(); + @PUT + @Path("/state/{state}") + @Operation(description = "Update feature toggle state for all features") + Response setAllFeatures(@PathParam("state") boolean state); - @PUT - @Path("/{featureName}/state/{state}") - @Operation(description = "Update feature toggle state") - Response setFeatureState(@PathParam("featureName") String featureName, @PathParam("state") boolean state); + @PUT + @Path("/{featureName}/state/{state}") + @Operation(description = "Update feature toggle state") + Response setFeatureState(@PathParam("featureName") String featureName, @PathParam("state") boolean state); - @GET - @Path("/{featureName}/state") - @Operation(description = "Get feature toggle state", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = FeatureDto.class)))) - Response getFeatureState(@PathParam("featureName") String featureName); + @GET + @Path("/{featureName}/state") + @Operation(description = "Get feature toggle state", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = FeatureDto.class)))) + Response getFeatureState(@PathParam("featureName") String featureName); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/mapping/MapToggleableFeatureToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/mapping/MapToggleableFeatureToDto.java index c6fbed672e..47cd79bdf0 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/mapping/MapToggleableFeatureToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/mapping/MapToggleableFeatureToDto.java @@ -28,9 +28,8 @@ public class MapToggleableFeatureToDto extends MappingBase<Collection<Toggleable @Override public void doMapping(Collection<ToggleableFeature> source, FeatureSetDto target) { - if (source != null && !source.isEmpty()){ - Set<FeatureDto> fDtos = source.stream().map(f -> new FeatureDto(f.name(), f.isActive())) - .collect(Collectors.toSet()); + if (source != null && !source.isEmpty()) { + Set<FeatureDto> fDtos = source.stream().map(f -> new FeatureDto(f.name(), f.isActive())).collect(Collectors.toSet()); target.setFeatures(fDtos); } else { target.setFeatures(Collections.emptySet()); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/services/TogglzFeaturesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/services/TogglzFeaturesImpl.java index 4777d0a656..b4e9db695a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/services/TogglzFeaturesImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-services/src/main/java/org/openecomp/sdcrests/togglz/rest/services/TogglzFeaturesImpl.java @@ -13,13 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.togglz.rest.services; + +import java.util.Arrays; +import javax.inject.Named; +import javax.ws.rs.core.Response; +import org.openecomp.sdc.be.togglz.ToggleableFeature; import org.openecomp.sdcrests.togglz.rest.TogglzFeatures; import org.openecomp.sdcrests.togglz.rest.mapping.MapToggleableFeatureToDto; import org.openecomp.sdcrests.togglz.types.FeatureDto; import org.openecomp.sdcrests.togglz.types.FeatureSetDto; -import org.openecomp.sdc.be.togglz.ToggleableFeature; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import org.togglz.core.Feature; @@ -27,10 +30,6 @@ import org.togglz.core.context.FeatureContext; import org.togglz.core.repository.FeatureState; import org.togglz.core.util.NamedFeature; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Arrays; - @Named @Service("TogglzFeature") @Scope(value = "prototype") @@ -49,7 +48,7 @@ public class TogglzFeaturesImpl implements TogglzFeatures { new MapToggleableFeatureToDto().doMapping(Arrays.asList(ToggleableFeature.values()), featureSetDto); featureSetDto.getFeatures().forEach(featureDto -> { Feature feature = new NamedFeature(featureDto.getName()); - FeatureState featureState = new FeatureState(feature,active); + FeatureState featureState = new FeatureState(feature, active); FeatureContext.getFeatureManager().setFeatureState(featureState); }); return Response.ok().build(); @@ -58,7 +57,7 @@ public class TogglzFeaturesImpl implements TogglzFeatures { @Override public Response setFeatureState(String featureName, boolean active) { Feature feature = new NamedFeature(featureName); - FeatureState featureState = new FeatureState(feature,active); + FeatureState featureState = new FeatureState(feature, active); FeatureContext.getFeatureManager().setFeatureState(featureState); return Response.ok().build(); } @@ -66,10 +65,7 @@ public class TogglzFeaturesImpl implements TogglzFeatures { @Override public Response getFeatureState(String featureName) { boolean active = ToggleableFeature.valueOf(featureName).isActive(); - FeatureDto featureDto = new FeatureDto(featureName,active); - + FeatureDto featureDto = new FeatureDto(featureName, active); return Response.ok(featureDto).build(); } - } - diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-types/src/main/java/org/openecomp/sdcrests/togglz/types/FeatureDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-types/src/main/java/org/openecomp/sdcrests/togglz/types/FeatureDto.java index d6e2fbd669..786ee06c3a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-types/src/main/java/org/openecomp/sdcrests/togglz/types/FeatureDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-types/src/main/java/org/openecomp/sdcrests/togglz/types/FeatureDto.java @@ -18,7 +18,7 @@ package org.openecomp.sdcrests.togglz.types; import java.util.Objects; public class FeatureDto { - + private final String name; private final boolean active; @@ -37,8 +37,12 @@ public class FeatureDto { @Override public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof FeatureDto)) return false; + if (this == o) { + return true; + } + if (!(o instanceof FeatureDto)) { + return false; + } FeatureDto that = (FeatureDto) o; return Objects.equals(getName(), that.getName()); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-types/src/main/java/org/openecomp/sdcrests/togglz/types/FeatureSetDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-types/src/main/java/org/openecomp/sdcrests/togglz/types/FeatureSetDto.java index cf7ee71a35..6862041b63 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-types/src/main/java/org/openecomp/sdcrests/togglz/types/FeatureSetDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/togglz-rest/togglz-rest-types/src/main/java/org/openecomp/sdcrests/togglz/types/FeatureSetDto.java @@ -18,7 +18,7 @@ package org.openecomp.sdcrests.togglz.types; import java.util.Set; public class FeatureSetDto { - + private Set<FeatureDto> features; public Set<FeatureDto> getFeatures() { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org/openecomp/sdcrests/uniquevalue/rest/UniqueTypes.java b/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org/openecomp/sdcrests/uniquevalue/rest/UniqueTypes.java index 2e91c7a6b7..1bd3b460f7 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org/openecomp/sdcrests/uniquevalue/rest/UniqueTypes.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org/openecomp/sdcrests/uniquevalue/rest/UniqueTypes.java @@ -15,22 +15,24 @@ */ package org.openecomp.sdcrests.uniquevalue.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.springframework.validation.annotation.Validated; - import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/unique-types") @Produces(MediaType.APPLICATION_JSON) @@ -39,19 +41,17 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface UniqueTypes { - @GET - @Path("/") - @Operation(description = "Lists unique value types") - Response listUniqueTypes(@NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "Lists unique value types") + Response listUniqueTypes(@NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{type}/values/{value}") - @Operation(description = "Gets unique value") - @ApiResponse(responseCode = "200", description = "Indication whether the unique value is occupied") - @ApiResponse(responseCode = "404", description = "Unsupported unique type") - Response getUniqueValue( - @Parameter(description = "The unique value type, for example: 'VlmName'") @PathParam("type") String type, - @Parameter(description = "The unique value") @PathParam("value") String value, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{type}/values/{value}") + @Operation(description = "Gets unique value") + @ApiResponse(responseCode = "200", description = "Indication whether the unique value is occupied") + @ApiResponse(responseCode = "404", description = "Unsupported unique type") + Response getUniqueValue(@Parameter(description = "The unique value type, for example: 'VlmName'") @PathParam("type") String type, + @Parameter(description = "The unique value") @PathParam("value") String value, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org/openecomp/sdcrests/uniquevalue/rest/services/UniqueTypesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org/openecomp/sdcrests/uniquevalue/rest/services/UniqueTypesImpl.java index 0e657903b6..4df0ff5532 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org/openecomp/sdcrests/uniquevalue/rest/services/UniqueTypesImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-services/src/main/java/org/openecomp/sdcrests/uniquevalue/rest/services/UniqueTypesImpl.java @@ -18,7 +18,16 @@ */ package org.openecomp.sdcrests.uniquevalue.rest.services; +import static javax.ws.rs.core.Response.Status.NOT_FOUND; + import com.google.common.annotations.VisibleForTesting; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.ServiceLoader; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.core.dao.UniqueValueDaoFactory; import org.openecomp.core.util.UniqueValueUtil; import org.openecomp.sdc.common.errors.ErrorCategory; @@ -30,65 +39,48 @@ import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; - -import java.util.*; - -import static javax.ws.rs.core.Response.Status.NOT_FOUND; - @Named @Service("uniqueTypes") @Scope(value = "prototype") public class UniqueTypesImpl implements UniqueTypes { - private static final String UNIQUE_TYPE_NOT_FOUND_ERR_ID = "UNIQUE_TYPE_NOT_FOUND"; - private static final String UNIQUE_TYPE_NOT_FOUND_MSG = "%s is not a supported unique type."; - - private static final Map<String, String> UNIQUE_TYPE_TO_INTERNAL; - private UniqueValueUtil uniqueValueUtil; - - static { - Map<String, String> uniqueTypes = new HashMap<>(); - ServiceLoader.load(UniqueTypesProvider.class) - .forEach(typesProvider -> uniqueTypes.putAll(typesProvider.listUniqueTypes())); - UNIQUE_TYPE_TO_INTERNAL = Collections.unmodifiableMap(uniqueTypes); - } + private static final String UNIQUE_TYPE_NOT_FOUND_ERR_ID = "UNIQUE_TYPE_NOT_FOUND"; + private static final String UNIQUE_TYPE_NOT_FOUND_MSG = "%s is not a supported unique type."; + private static final Map<String, String> UNIQUE_TYPE_TO_INTERNAL; + static { + Map<String, String> uniqueTypes = new HashMap<>(); + ServiceLoader.load(UniqueTypesProvider.class).forEach(typesProvider -> uniqueTypes.putAll(typesProvider.listUniqueTypes())); + UNIQUE_TYPE_TO_INTERNAL = Collections.unmodifiableMap(uniqueTypes); + } - @Override - public Response listUniqueTypes(String user) { - return Response.ok( - new GenericCollectionWrapper<>(new ArrayList<>(UNIQUE_TYPE_TO_INTERNAL.keySet()))) - .build(); - } - - @Override - public Response getUniqueValue(String type, String value, String user) { - String internalType = UNIQUE_TYPE_TO_INTERNAL.get(type); + private UniqueValueUtil uniqueValueUtil; - if (internalType == null) { - ErrorCode error = new ErrorCode.ErrorCodeBuilder() - .withCategory(ErrorCategory.APPLICATION) - .withId(UNIQUE_TYPE_NOT_FOUND_ERR_ID) - .withMessage(String.format(UNIQUE_TYPE_NOT_FOUND_MSG, type)).build(); - return Response.status(NOT_FOUND).entity(new ErrorCodeAndMessage(NOT_FOUND, error)).build(); + @Override + public Response listUniqueTypes(String user) { + return Response.ok(new GenericCollectionWrapper<>(new ArrayList<>(UNIQUE_TYPE_TO_INTERNAL.keySet()))).build(); } - return Response.ok(Collections - .singletonMap("occupied", getUniqueValueUtil().isUniqueValueOccupied(internalType, value))) - .build(); - } + @Override + public Response getUniqueValue(String type, String value, String user) { + String internalType = UNIQUE_TYPE_TO_INTERNAL.get(type); + if (internalType == null) { + ErrorCode error = new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).withId(UNIQUE_TYPE_NOT_FOUND_ERR_ID) + .withMessage(String.format(UNIQUE_TYPE_NOT_FOUND_MSG, type)).build(); + return Response.status(NOT_FOUND).entity(new ErrorCodeAndMessage(NOT_FOUND, error)).build(); + } + return Response.ok(Collections.singletonMap("occupied", getUniqueValueUtil().isUniqueValueOccupied(internalType, value))).build(); + } - @VisibleForTesting - void setUniqueValueUtil(UniqueValueUtil uniqueValueUtil) { - this.uniqueValueUtil = uniqueValueUtil; - } + private UniqueValueUtil getUniqueValueUtil() { + if (uniqueValueUtil == null) { + uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface()); + } + return uniqueValueUtil; + } - private UniqueValueUtil getUniqueValueUtil() { - if (uniqueValueUtil == null){ - uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface()); + @VisibleForTesting + void setUniqueValueUtil(UniqueValueUtil uniqueValueUtil) { + this.uniqueValueUtil = uniqueValueUtil; } - return uniqueValueUtil; - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-types/src/main/java/org/openecomp/sdcrests/uniquevalue/types/UniqueTypesProvider.java b/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-types/src/main/java/org/openecomp/sdcrests/uniquevalue/types/UniqueTypesProvider.java index 986667227c..533ba46e59 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-types/src/main/java/org/openecomp/sdcrests/uniquevalue/types/UniqueTypesProvider.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/unique-type-rest/unique-type-rest-types/src/main/java/org/openecomp/sdcrests/uniquevalue/types/UniqueTypesProvider.java @@ -18,12 +18,10 @@ package org.openecomp.sdcrests.uniquevalue.types; import java.util.Map; /** - * The unique value service exposes APIs to list unique types and check whether a value is - * already taken. - * The modules which uses the unique value logic and would like to enable these APIs must - * implement this class. + * The unique value service exposes APIs to list unique types and check whether a value is already taken. The modules which uses the unique value + * logic and would like to enable these APIs must implement this class. */ public interface UniqueTypesProvider { - Map<String, String> listUniqueTypes(); + Map<String, String> listUniqueTypes(); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java index ec8c8eb945..e354abf85a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/Validation.java @@ -13,33 +13,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.validation.rest; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.apache.cxf.jaxrs.ext.multipart.Multipart; -import org.springframework.validation.annotation.Validated; - -import javax.ws.rs.*; +import java.io.InputStream; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.InputStream; - +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/validation") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Validation")}) @Validated - public interface Validation { - - @POST - @Path("{type}/validate") - @Consumes(MediaType.MULTIPART_FORM_DATA) - Response validateFile(@PathParam("type") String type, - @Multipart("validate") InputStream fileToValidate); + @POST + @Path("{type}/validate") + @Consumes(MediaType.MULTIPART_FORM_DATA) + Response validateFile(@PathParam("type") String type, @Multipart("validate") InputStream fileToValidate); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/ValidationForSwaggerUsage.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/ValidationForSwaggerUsage.java index e184b9e2a4..ac4f0ad64d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/ValidationForSwaggerUsage.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/ValidationForSwaggerUsage.java @@ -13,35 +13,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.validation.rest; import com.sun.jersey.multipart.FormDataParam; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.springframework.validation.annotation.Validated; - -import javax.ws.rs.*; +import java.io.InputStream; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.InputStream; - +import org.springframework.validation.annotation.Validated; @Path("/v1.0/validation") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Validation")}) @Validated - public interface ValidationForSwaggerUsage { - - @POST - @Path("{type}/validate") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Operation(description = "Validate a package") - Response validateFile(@PathParam("type") String type, - @FormDataParam("validate") InputStream fileToValidate); + @POST + @Path("{type}/validate") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Operation(description = "Validate a package") + Response validateFile(@PathParam("type") String type, @FormDataParam("validate") InputStream fileToValidate); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/mapping/MapValidationFileResponseToValidationFileResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/mapping/MapValidationFileResponseToValidationFileResponseDto.java index 9f8ae80e18..99e375d07e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/mapping/MapValidationFileResponseToValidationFileResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/mapping/MapValidationFileResponseToValidationFileResponseDto.java @@ -13,10 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.validation.rest.mapping; - import org.openecomp.sdc.validation.types.ValidationFileResponse; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.validation.types.ValidationFileResponseDto; @@ -24,10 +22,10 @@ import org.openecomp.sdcrests.validation.types.ValidationFileResponseDto; /** * Created by TALIO on 4/27/2016. */ -public class MapValidationFileResponseToValidationFileResponseDto - extends MappingBase<ValidationFileResponse, ValidationFileResponseDto> { - @Override - public void doMapping(ValidationFileResponse source, ValidationFileResponseDto target) { - target.setValidationData(source.getValidationData()); - } +public class MapValidationFileResponseToValidationFileResponseDto extends MappingBase<ValidationFileResponse, ValidationFileResponseDto> { + + @Override + public void doMapping(ValidationFileResponse source, ValidationFileResponseDto target) { + target.setValidationData(source.getValidationData()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java index 1ece6f75f8..da604b7cb1 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/services/ValidationImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,10 +19,12 @@ * Modifications copyright (c) 2019 Nokia * ================================================================================ */ - package org.openecomp.sdcrests.validation.rest.services; - +import java.io.IOException; +import java.io.InputStream; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.sdc.validation.UploadValidationManager; import org.openecomp.sdc.validation.types.ValidationFileResponse; import org.openecomp.sdcrests.validation.rest.Validation; @@ -32,37 +34,28 @@ 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.IOException; -import java.io.InputStream; - @Named @Service("validation") @Scope(value = "prototype") public class ValidationImpl implements Validation { - private final UploadValidationManager uploadValidationManager; - - @Autowired - public ValidationImpl(UploadValidationManager uploadValidationManager) { - this.uploadValidationManager = uploadValidationManager; - } + private final UploadValidationManager uploadValidationManager; - @Override - public Response validateFile(String type, InputStream fileToValidate) { - ValidationFileResponse validationFileResponse; - try { - validationFileResponse = uploadValidationManager.validateFile(type, fileToValidate); - } catch (IOException exception) { - throw new RuntimeException(exception); + @Autowired + public ValidationImpl(UploadValidationManager uploadValidationManager) { + this.uploadValidationManager = uploadValidationManager; } - ValidationFileResponseDto validationFileResponseDto = - new MapValidationFileResponseToValidationFileResponseDto() + @Override + public Response validateFile(String type, InputStream fileToValidate) { + ValidationFileResponse validationFileResponse; + try { + validationFileResponse = uploadValidationManager.validateFile(type, fileToValidate); + } catch (IOException exception) { + throw new RuntimeException(exception); + } + ValidationFileResponseDto validationFileResponseDto = new MapValidationFileResponseToValidationFileResponseDto() .applyMapping(validationFileResponse, ValidationFileResponseDto.class); - return Response.ok(validationFileResponseDto).build(); - } - - + return Response.ok(validationFileResponseDto).build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/src/main/java/org/openecomp/sdcrests/validation/types/ValidationFileResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/src/main/java/org/openecomp/sdcrests/validation/types/ValidationFileResponseDto.java index 1ec6568a73..3e82a063b6 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/src/main/java/org/openecomp/sdcrests/validation/types/ValidationFileResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/src/main/java/org/openecomp/sdcrests/validation/types/ValidationFileResponseDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.validation.types; import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; @@ -26,16 +25,18 @@ import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; * Created by TALIO on 4/27/2016. */ public class ValidationFileResponseDto { - //private List<String> fileNames; - //private Map<String, List<ErrorMessage>> errors; - //private ValidationFileStatus status; - private ValidationStructureList validationData; + //private List<String> fileNames; + + //private Map<String, List<ErrorMessage>> errors; + + //private ValidationFileStatus status; + private ValidationStructureList validationData; - public ValidationStructureList getValidationData() { - return validationData; - } + public ValidationStructureList getValidationData() { + return validationData; + } - public void setValidationData(ValidationStructureList validationData) { - this.validationData = validationData; - } + public void setValidationData(ValidationStructureList validationData) { + this.validationData = validationData; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java index 7caa639bac..7225a36f55 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPoolLimits.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,102 +17,83 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; -import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; +import org.springframework.validation.annotation.Validated; -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-license-models/{vlmId}/versions/{versionId}/entitlement-pools/{entitlementPoolId}/limits") +@Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/entitlement-pools/{entitlementPoolId}/limits") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor License Model - Entitlement Pool Limits")}) @Validated public interface EntitlementPoolLimits { - @POST - @Path("/") - @Operation(description = "Create vendor entitlement pool limits") - Response createLimit(@Valid LimitRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam - ("versionId") - String versionId, - @Parameter(description = "Vendor license model Entitlement Pool Id") - @PathParam("entitlementPoolId") - String entitlementPoolId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - - @GET - @Path("/") - @Operation(description = "List vendor entitlement pool limits", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = LimitRequestDto.class))))) - Response listLimits( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor license model Entitlement Pool Id") @PathParam("entitlementPoolId") - String entitlementPoolId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @POST + @Path("/") + @Operation(description = "Create vendor entitlement pool limits") + Response createLimit(@Valid LimitRequestDto request, @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model Entitlement Pool Id") @PathParam("entitlementPoolId") String entitlementPoolId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{limitId}") - @Operation(description = "Update vendor entitlement pool limit") - Response updateLimit(@Valid LimitRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam - ("versionId") - String versionId, - @Parameter(description = "Vendor license model Entitlement Pool Id") - @PathParam("entitlementPoolId") - String entitlementPoolId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @PathParam("limitId") String limitId, - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "List vendor entitlement pool limits", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = LimitRequestDto.class))))) + Response listLimits(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model Entitlement Pool Id") @PathParam("entitlementPoolId") String entitlementPoolId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{limitId}") - @Operation(description = "Get vendor entitlement pool limit", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LimitEntityDto.class)))) - Response getLimit( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor license model Entitlement Pool Id") @PathParam - ("entitlementPoolId") String entitlementPoolId, - @Parameter(description = "Vendor license model Entitlement Pool Limit Id") @PathParam("limitId") - String limitId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{limitId}") + @Operation(description = "Update vendor entitlement pool limit") + Response updateLimit(@Valid LimitRequestDto request, @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model Entitlement Pool Id") @PathParam("entitlementPoolId") String entitlementPoolId, + @NotNull(message = USER_MISSING_ERROR_MSG) @PathParam("limitId") String limitId, + @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{limitId}") - @Operation(description = "Delete vendor entitlement pool limit") - Response deleteLimit( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor license model Entitlement pool Id") @PathParam("entitlementPoolId") - String entitlementPoolId, - @PathParam("limitId") String limitId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{limitId}") + @Operation(description = "Get vendor entitlement pool limit", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LimitEntityDto.class)))) + Response getLimit(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model Entitlement Pool Id") @PathParam("entitlementPoolId") String entitlementPoolId, + @Parameter(description = "Vendor license model Entitlement Pool Limit Id") @PathParam("limitId") String limitId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{limitId}") + @Operation(description = "Delete vendor entitlement pool limit") + Response deleteLimit(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model Entitlement pool Id") @PathParam("entitlementPoolId") String entitlementPoolId, + @PathParam("limitId") String limitId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPools.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPools.java index 89b632f2e5..b2d320023e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPools.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/EntitlementPools.java @@ -17,30 +17,35 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; -import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolRequestDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolRequestDto; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/entitlement-pools") @Produces(MediaType.APPLICATION_JSON) @@ -48,52 +53,44 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor License Model - Entitlement Pools")}) @Validated public interface EntitlementPools { + @GET @Path("/") - @Operation(description = "List vendor entitlement pools", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = EntitlementPoolEntityDto.class))))) - Response listEntitlementPools( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @Operation(description = "List vendor entitlement pools", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = EntitlementPoolEntityDto.class))))) + Response listEntitlementPools(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/") @Operation(description = "Create vendor entitlement pool") Response createEntitlementPool(@Valid EntitlementPoolRequestDto request, @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam ("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @Path("/{entitlementPoolId}") @Operation(description = "Update vendor entitlement pool") Response updateEntitlementPool(@Valid EntitlementPoolRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @PathParam("entitlementPoolId") String entitlementPoolId, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @PathParam("entitlementPoolId") String entitlementPoolId, @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @Path("/{entitlementPoolId}") @Operation(description = "Get vendor entitlement pool", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = EntitlementPoolEntityDto.class)))) - Response getEntitlementPool( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("entitlementPoolId") String entitlementPoolId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + Response getEntitlementPool(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("entitlementPoolId") String entitlementPoolId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{entitlementPoolId}") @Operation(description = "Delete vendor entitlement pool") - Response deleteEntitlementPool( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("entitlementPoolId") String entitlementPoolId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - + Response deleteEntitlementPool(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("entitlementPoolId") String entitlementPoolId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java index 80403f59e1..efb6479b0f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/FeatureGroups.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,34 +17,38 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupEntityDto; import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupModelDto; import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupRequestDto; import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupUpdateRequestDto; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - - @Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/feature-groups") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -52,51 +56,43 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface FeatureGroups { - @GET - @Path("/") - @Operation(description = "List vendor feature groups",responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation =FeatureGroupEntityDto.class))))) - Response listFeatureGroups( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @POST - @Path("/") - @Operation(description = "Create vendor feature group") - Response createFeatureGroup(@Valid FeatureGroupRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "List vendor feature groups", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = FeatureGroupEntityDto.class))))) + Response listFeatureGroups(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{featureGroupId}") - @Operation(description = "Update vendor feature group") - Response updateFeatureGroup(@Valid FeatureGroupUpdateRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("featureGroupId") String featureGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @POST + @Path("/") + @Operation(description = "Create vendor feature group") + Response createFeatureGroup(@Valid FeatureGroupRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{featureGroupId}") - @Operation(description = "Get vendor feature group", responses = @ApiResponse(content = @Content(schema = @Schema(implementation =FeatureGroupModelDto.class)))) - Response getFeatureGroup( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("featureGroupId") String featureGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{featureGroupId}") + @Operation(description = "Update vendor feature group") + Response updateFeatureGroup(@Valid FeatureGroupUpdateRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("featureGroupId") String featureGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{featureGroupId}") - @Operation(description = "Delete vendor feature group") - Response deleteFeatureGroup( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("featureGroupId") String featureGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{featureGroupId}") + @Operation(description = "Get vendor feature group", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = FeatureGroupModelDto.class)))) + Response getFeatureGroup(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("featureGroupId") String featureGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{featureGroupId}") + @Operation(description = "Delete vendor feature group") + Response deleteFeatureGroup(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("featureGroupId") String featureGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseAgreements.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseAgreements.java index 0d384ed7bb..d74ddaa8fe 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseAgreements.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseAgreements.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,89 +17,82 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementEntityDto; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementModelDto; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementRequestDto; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementUpdateRequestDto; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - - @Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/license-agreements") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor License Model - License Agreements")}) @Validated - public interface LicenseAgreements { - @GET - @Path("/") - @Operation(description = "List vendor license agreements", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation =LicenseAgreementEntityDto.class))))) - Response listLicenseAgreements( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @POST - @Path("/") - @Operation(description = "Create vendor license agreement") - Response createLicenseAgreement(@Valid LicenseAgreementRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "List vendor license agreements", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = LicenseAgreementEntityDto.class))))) + Response listLicenseAgreements(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{licenseAgreementId}") - @Operation(description = "Update vendor license agreement") - Response updateLicenseAgreement(@Valid LicenseAgreementUpdateRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") - @PathParam("versionId") String versionId, - @PathParam("licenseAgreementId") String licenseAgreementId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @POST + @Path("/") + @Operation(description = "Create vendor license agreement") + Response createLicenseAgreement(@Valid LicenseAgreementRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{licenseAgreementId}") - @Operation(description = "Get vendor license agreement", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LicenseAgreementModelDto.class)))) - Response getLicenseAgreement( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("licenseAgreementId") String licenseAgreementId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{licenseAgreementId}") + @Operation(description = "Update vendor license agreement") + Response updateLicenseAgreement(@Valid LicenseAgreementUpdateRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("licenseAgreementId") String licenseAgreementId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{licenseAgreementId}") - @Operation(description = "Delete vendor license agreement") - Response deleteLicenseAgreement( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("licenseAgreementId") String licenseAgreementId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{licenseAgreementId}") + @Operation(description = "Get vendor license agreement", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LicenseAgreementModelDto.class)))) + Response getLicenseAgreement(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("licenseAgreementId") String licenseAgreementId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{licenseAgreementId}") + @Operation(description = "Delete vendor license agreement") + Response deleteLicenseAgreement(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("licenseAgreementId") String licenseAgreementId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java index afa9663b10..898f084d5f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroupLimits.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,100 +17,83 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; -import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; +import org.springframework.validation.annotation.Validated; -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-license-models/{vlmId}/versions/{versionId}/license-key-groups/{licenseKeyGroupId}/limits") +@Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/license-key-groups/{licenseKeyGroupId}/limits") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor License Model - License Key Group Limits")}) @Validated public interface LicenseKeyGroupLimits { - @POST - @Path("/") - @Operation(description = "Create vendor license key group limit") - Response createLimit(@Valid LimitRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam - ("versionId") - String versionId, - @Parameter(description = "Vendor license model License Key Group Id") - @PathParam("licenseKeyGroupId") - String licenseKeyGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @POST + @Path("/") + @Operation(description = "Create vendor license key group limit") + Response createLimit(@Valid LimitRequestDto request, @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model License Key Group Id") @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/") - @Operation(description = "List vendor license key group limits", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = LimitEntityDto.class))))) - Response listLimits( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor license model License Key Group Id") @PathParam("licenseKeyGroupId") - String licenseKeyGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "List vendor license key group limits", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = LimitEntityDto.class))))) + Response listLimits(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model License Key Group Id") @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{limitId}") - @Operation(description = "Update vendor license key group limit") - Response updateLimit(@Valid LimitRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam - ("versionId") - String versionId, - @Parameter(description = "Vendor license model License Key Group Id") - @PathParam("licenseKeyGroupId") - String licenseKeyGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @PathParam("limitId") String limitId, - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{limitId}") + @Operation(description = "Update vendor license key group limit") + Response updateLimit(@Valid LimitRequestDto request, @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model License Key Group Id") @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @PathParam("limitId") String limitId, + @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{limitId}") - @Operation(description = "Get vendor entitlement pool limit", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LimitEntityDto.class)))) - Response getLimit( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor license model License Key Group") @PathParam - ("licenseKeyGroupId") String entitlementPoolId, - @Parameter(description = "Vendor license model License Key Group Limit Id") @PathParam("limitId") - String limitId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{limitId}") + @Operation(description = "Get vendor entitlement pool limit", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LimitEntityDto.class)))) + Response getLimit(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model License Key Group") @PathParam("licenseKeyGroupId") String entitlementPoolId, + @Parameter(description = "Vendor license model License Key Group Limit Id") @PathParam("limitId") String limitId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{limitId}") - @Operation(description = "Delete vendor license key group limit") - Response deleteLimit( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor license model license key group Id") @PathParam("licenseKeyGroupId") - String licenseKeyGroupId, - @PathParam("limitId") String limitId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{limitId}") + @Operation(description = "Delete vendor license key group limit") + Response deleteLimit(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor license model license key group Id") @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @PathParam("limitId") String limitId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroups.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroups.java index 50dc3c82a1..2bb565b124 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroups.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/LicenseKeyGroups.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,31 +17,35 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; -import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupRequestDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - +import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; +import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupRequestDto; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/vendor-license-models/{vlmId}/versions/{versionId}/license-key-groups") @Produces(MediaType.APPLICATION_JSON) @@ -49,52 +53,44 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor License Model - License Key Groups")}) @Validated public interface LicenseKeyGroups { - @GET - @Path("/") - @Operation(description = "List vendor license key groups", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation =LicenseKeyGroupEntityDto.class))))) - Response listLicenseKeyGroups( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/") - @Operation(description = "Create vendor license key group") - Response createLicenseKeyGroup(@Valid LicenseKeyGroupRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "List vendor license key groups", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = LicenseKeyGroupEntityDto.class))))) + Response listLicenseKeyGroups(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @POST + @Path("/") + @Operation(description = "Create vendor license key group") + Response createLicenseKeyGroup(@Valid LicenseKeyGroupRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{licenseKeyGroupId}") - @Operation(description = "Update vendor license key group") - Response updateLicenseKeyGroup(@Valid LicenseKeyGroupRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") - @PathParam("versionId") String versionId, - @PathParam("licenseKeyGroupId") String licenseKeyGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{licenseKeyGroupId}") + @Operation(description = "Update vendor license key group") + Response updateLicenseKeyGroup(@Valid LicenseKeyGroupRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{licenseKeyGroupId}") - @Operation(description = "Get vendor license key group",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LicenseKeyGroupEntityDto.class)))) - Response getLicenseKeyGroup( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("licenseKeyGroupId") String licenseKeyGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{licenseKeyGroupId}") + @Operation(description = "Get vendor license key group", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = LicenseKeyGroupEntityDto.class)))) + Response getLicenseKeyGroup(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{licenseKeyGroupId}") - @Operation(description = "Delete vendor license key group") - Response deleteLicenseKeyGroup( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, - @PathParam("licenseKeyGroupId") String licenseKeyGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{licenseKeyGroupId}") + @Operation(description = "Delete vendor license key group") + Response deleteLicenseKeyGroup(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @PathParam("licenseKeyGroupId") String licenseKeyGroupId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java index 3778129f7f..0636b6e599 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/VendorLicenseModels.java @@ -13,19 +13,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.openecomp.sdcrests.vendorlicense.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdcrests.common.RestConstants; import org.openecomp.sdcrests.item.types.ItemDto; import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelActionRequestDto; @@ -33,15 +46,6 @@ import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto; import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelRequestDto; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - - @Path("/v1.0/vendor-license-models") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -49,64 +53,48 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface VendorLicenseModels { - @GET - @Path("/") - @Operation(description = "List vendor license models", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation=ItemDto.class))))) - Response listLicenseModels(@Parameter(description = "Filter to return only Vendor License Models with at" + - " least one version at this status. Currently supported values: 'Certified' , 'Draft'") - @QueryParam("versionFilter") String versionStatus, - @Parameter(description = "Filter to only return Vendor License Models at this status." + - "Currently supported values: 'ACTIVE' , 'ARCHIVED'." + - "Default value = 'ACTIVE'.") - @QueryParam("Status") String itemStatus, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); - - @POST - @Path("/") - @Operation(description = "Create vendor license model") - Response createLicenseModel(@Valid VendorLicenseModelRequestDto request, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); + @GET + @Path("/") + @Operation(description = "List vendor license models", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ItemDto.class))))) + Response listLicenseModels(@Parameter(description = "Filter to return only Vendor License Models with at" + + " least one version at this status. Currently supported values: 'Certified' , 'Draft'") @QueryParam("versionFilter") String versionStatus, + @Parameter(description = "Filter to only return Vendor License Models at this status." + + "Currently supported values: 'ACTIVE' , 'ARCHIVED'." + + "Default value = 'ACTIVE'.") @QueryParam("Status") String itemStatus, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{vlmId}") - @Operation(description = "Delete vendor license model") - Response deleteLicenseModel( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create vendor license model") + Response createLicenseModel(@Valid VendorLicenseModelRequestDto request, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{vlmId}/versions/{versionId}") - @Operation(description = "Update vendor license model") - Response updateLicenseModel(@Valid VendorLicenseModelRequestDto request, - @Parameter(description = "Vendor license model Id") - @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{vlmId}") + @Operation(description = "Delete vendor license model") + Response deleteLicenseModel(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{vlmId}/versions/{versionId}") - @Operation(description = "Get vendor license model", responses = @ApiResponse(content = @Content(schema = @Schema(implementation=VendorLicenseModelEntityDto.class)))) - Response getLicenseModel( - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam - ("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) - String user); + @PUT + @Path("/{vlmId}/versions/{versionId}") + @Operation(description = "Update vendor license model") + Response updateLicenseModel(@Valid VendorLicenseModelRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{vlmId}/versions/{versionId}") + @Operation(description = "Get vendor license model", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = VendorLicenseModelEntityDto.class)))) + Response getLicenseModel(@Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{vlmId}/versions/{versionId}/actions") - @Operation(description = "Update vendor license model") - Response actOnLicenseModel(@Valid VendorLicenseModelActionRequestDto request, - @Parameter(description = "Vendor license model Id") @PathParam("vlmId") - String vlmId, - @Parameter(description = "Vendor license model version Id") @PathParam - ("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{vlmId}/versions/{versionId}/actions") + @Operation(description = "Update vendor license model") + Response actOnLicenseModel(@Valid VendorLicenseModelActionRequestDto request, + @Parameter(description = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @Parameter(description = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java index 35833e9621..05d2d1ac77 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/LimitCreationDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,17 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; public class LimitCreationDto { - private String limitId; - public String getLimitId() { - return limitId; - } + private String limitId; + + public String getLimitId() { + return limitId; + } - public void setLimitId(String limitId) { - this.limitId = limitId; - } + public void setLimitId(String limitId) { + this.limitId = limitId; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherDtoToChoiceOrOther.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherDtoToChoiceOrOther.java index 28eeb29018..f4b6119056 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherDtoToChoiceOrOther.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherDtoToChoiceOrOther.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,20 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.ChoiceOrOtherDto; -public class MapChoiceOrOtherDtoToChoiceOrOther - extends MappingBase<ChoiceOrOtherDto, ChoiceOrOther> { +public class MapChoiceOrOtherDtoToChoiceOrOther extends MappingBase<ChoiceOrOtherDto, ChoiceOrOther> { - @Override - public void doMapping(ChoiceOrOtherDto source, ChoiceOrOther target) { - target.setChoice(source.getChoice()); - target.setOther(source.getOther()); - target.setResult(null); - } + @Override + public void doMapping(ChoiceOrOtherDto source, ChoiceOrOther target) { + target.setChoice(source.getChoice()); + target.setOther(source.getOther()); + target.setResult(null); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherToChoiceOrOtherDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherToChoiceOrOtherDto.java index 2d686110d5..aad72491ac 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherToChoiceOrOtherDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapChoiceOrOtherToChoiceOrOtherDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,19 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.ChoiceOrOtherDto; -public class MapChoiceOrOtherToChoiceOrOtherDto - extends MappingBase<ChoiceOrOther, ChoiceOrOtherDto> { +public class MapChoiceOrOtherToChoiceOrOtherDto extends MappingBase<ChoiceOrOther, ChoiceOrOtherDto> { - @Override - public void doMapping(ChoiceOrOther source, ChoiceOrOtherDto target) { - target.setChoice(source.getChoice()); - target.setOther(source.getOther()); - } + @Override + public void doMapping(ChoiceOrOther source, ChoiceOrOtherDto target) { + target.setChoice(source.getChoice()); + target.setOther(source.getOther()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java index 2510bd0634..6dc6e6af92 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolEntityToEntitlementPoolEntityDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; @@ -25,26 +24,23 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto; -public class MapEntitlementPoolEntityToEntitlementPoolEntityDto - extends MappingBase<EntitlementPoolEntity, EntitlementPoolEntityDto> { - @Override - public void doMapping(EntitlementPoolEntity source, EntitlementPoolEntityDto target) { - target.setId(source.getId()); - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setType(source.getType()); - target.setThresholdValue(source.getThresholdValue()); - target.setThresholdUnits(source.getThresholdUnit()); - target.setIncrements(source.getIncrements()); - - target.setOperationalScope(new MapMultiChoiceOrOtherToMultiChoiceOrOtherDto() - .applyMapping(source.getOperationalScope(), MultiChoiceOrOtherDto.class)); - - target.setReferencingFeatureGroups(source.getReferencingFeatureGroups()); +public class MapEntitlementPoolEntityToEntitlementPoolEntityDto extends MappingBase<EntitlementPoolEntity, EntitlementPoolEntityDto> { - target.setStartDate(source.getStartDate()); - target.setExpiryDate(source.getExpiryDate()); - target.setVersionUUID(source.getVersionUuId()); - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - } + @Override + public void doMapping(EntitlementPoolEntity source, EntitlementPoolEntityDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setType(source.getType()); + target.setThresholdValue(source.getThresholdValue()); + target.setThresholdUnits(source.getThresholdUnit()); + target.setIncrements(source.getIncrements()); + target.setOperationalScope( + new MapMultiChoiceOrOtherToMultiChoiceOrOtherDto().applyMapping(source.getOperationalScope(), MultiChoiceOrOtherDto.class)); + target.setReferencingFeatureGroups(source.getReferencingFeatureGroups()); + target.setStartDate(source.getStartDate()); + target.setExpiryDate(source.getExpiryDate()); + target.setVersionUUID(source.getVersionUuId()); + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java index 5c45ed652a..1058a869aa 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapEntitlementPoolRequestDtoToEntitlementPoolEntity.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; @@ -25,21 +24,20 @@ import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolRequestDto; -public class MapEntitlementPoolRequestDtoToEntitlementPoolEntity - extends MappingBase<EntitlementPoolRequestDto, EntitlementPoolEntity> { - @Override - public void doMapping(EntitlementPoolRequestDto source, EntitlementPoolEntity target) { - target.setName(source.getName()); - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - target.setDescription(source.getDescription()); - target.setType(source.getType()); - target.setThresholdValue(source.getThresholdValue()); - target.setThresholdUnit(source.getThresholdUnits()); - target.setIncrements(source.getIncrements()); - target.setOperationalScope(new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther() - .applyMapping(source.getOperationalScope(), MultiChoiceOrOther.class)); +public class MapEntitlementPoolRequestDtoToEntitlementPoolEntity extends MappingBase<EntitlementPoolRequestDto, EntitlementPoolEntity> { - target.setStartDate(source.getStartDate()); - target.setExpiryDate(source.getExpiryDate()); - } + @Override + public void doMapping(EntitlementPoolRequestDto source, EntitlementPoolEntity target) { + target.setName(source.getName()); + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); + target.setDescription(source.getDescription()); + target.setType(source.getType()); + target.setThresholdValue(source.getThresholdValue()); + target.setThresholdUnit(source.getThresholdUnits()); + target.setIncrements(source.getIncrements()); + target.setOperationalScope( + new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther().applyMapping(source.getOperationalScope(), MultiChoiceOrOther.class)); + target.setStartDate(source.getStartDate()); + target.setExpiryDate(source.getExpiryDate()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java index 5dbf087e45..e362c92196 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupDescriptorDtoToFeatureGroupEntity.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,19 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupDescriptorDto; -public class MapFeatureGroupDescriptorDtoToFeatureGroupEntity - extends MappingBase<FeatureGroupDescriptorDto, FeatureGroupEntity> { - @Override - public void doMapping(FeatureGroupDescriptorDto source, FeatureGroupEntity target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setPartNumber(source.getPartNumber()); - } -}
\ No newline at end of file +public class MapFeatureGroupDescriptorDtoToFeatureGroupEntity extends MappingBase<FeatureGroupDescriptorDto, FeatureGroupEntity> { + + @Override + public void doMapping(FeatureGroupDescriptorDto source, FeatureGroupEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setPartNumber(source.getPartNumber()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java index 70f5666bcb..ee8626abaa 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapFeatureGroupEntityToFeatureGroupDescriptorDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,19 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupDescriptorDto; -public class MapFeatureGroupEntityToFeatureGroupDescriptorDto - extends MappingBase<FeatureGroupEntity, FeatureGroupDescriptorDto> { - @Override - public void doMapping(FeatureGroupEntity source, FeatureGroupDescriptorDto target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setPartNumber(source.getPartNumber()); - } +public class MapFeatureGroupEntityToFeatureGroupDescriptorDto extends MappingBase<FeatureGroupEntity, FeatureGroupDescriptorDto> { + + @Override + public void doMapping(FeatureGroupEntity source, FeatureGroupDescriptorDto target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setPartNumber(source.getPartNumber()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity.java index f5ea8414d5..98d703299b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; @@ -25,14 +24,13 @@ import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementDescriptorDto; -public class MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity - extends MappingBase<LicenseAgreementDescriptorDto, LicenseAgreementEntity> { - @Override - public void doMapping(LicenseAgreementDescriptorDto source, LicenseAgreementEntity target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setLicenseTerm(new MapChoiceOrOtherDtoToChoiceOrOther() - .applyMapping(source.getLicenseTerm(), ChoiceOrOther.class)); - target.setRequirementsAndConstrains(source.getRequirementsAndConstrains()); - } +public class MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity extends MappingBase<LicenseAgreementDescriptorDto, LicenseAgreementEntity> { + + @Override + public void doMapping(LicenseAgreementDescriptorDto source, LicenseAgreementEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setLicenseTerm(new MapChoiceOrOtherDtoToChoiceOrOther().applyMapping(source.getLicenseTerm(), ChoiceOrOther.class)); + target.setRequirementsAndConstrains(source.getRequirementsAndConstrains()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementEntityToLicenseAgreementDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementEntityToLicenseAgreementDescriptorDto.java index 2fd4f669cf..46de11f021 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementEntityToLicenseAgreementDescriptorDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseAgreementEntityToLicenseAgreementDescriptorDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; @@ -25,14 +24,13 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.ChoiceOrOtherDto; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementDescriptorDto; -public class MapLicenseAgreementEntityToLicenseAgreementDescriptorDto - extends MappingBase<LicenseAgreementEntity, LicenseAgreementDescriptorDto> { - @Override - public void doMapping(LicenseAgreementEntity source, LicenseAgreementDescriptorDto target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setLicenseTerm(new MapChoiceOrOtherToChoiceOrOtherDto() - .applyMapping(source.getLicenseTerm(), ChoiceOrOtherDto.class)); - target.setRequirementsAndConstrains(source.getRequirementsAndConstrains()); - } +public class MapLicenseAgreementEntityToLicenseAgreementDescriptorDto extends MappingBase<LicenseAgreementEntity, LicenseAgreementDescriptorDto> { + + @Override + public void doMapping(LicenseAgreementEntity source, LicenseAgreementDescriptorDto target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setLicenseTerm(new MapChoiceOrOtherToChoiceOrOtherDto().applyMapping(source.getLicenseTerm(), ChoiceOrOtherDto.class)); + target.setRequirementsAndConstrains(source.getRequirementsAndConstrains()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java index c543cf402e..3690a7c5d3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; @@ -25,23 +24,23 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto; -public class MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto - extends MappingBase<LicenseKeyGroupEntity, LicenseKeyGroupEntityDto> { - @Override - public void doMapping(LicenseKeyGroupEntity source, LicenseKeyGroupEntityDto target) { - target.setId(source.getId()); - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setType(source.getType()); - target.setOperationalScope(new MapMultiChoiceOrOtherToMultiChoiceOrOtherDto() - .applyMapping(source.getOperationalScope(), MultiChoiceOrOtherDto.class)); - target.setReferencingFeatureGroups(source.getReferencingFeatureGroups()); - target.setStartDate(source.getStartDate()); - target.setExpiryDate(source.getExpiryDate()); - target.setThresholdUnits(source.getThresholdUnits()); - target.setThresholdValue(source.getThresholdValue()); - target.setIncrements(source.getIncrements()); - target.setVersionUUID(source.getVersionUuId()); - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - } +public class MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto extends MappingBase<LicenseKeyGroupEntity, LicenseKeyGroupEntityDto> { + + @Override + public void doMapping(LicenseKeyGroupEntity source, LicenseKeyGroupEntityDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setType(source.getType()); + target.setOperationalScope( + new MapMultiChoiceOrOtherToMultiChoiceOrOtherDto().applyMapping(source.getOperationalScope(), MultiChoiceOrOtherDto.class)); + target.setReferencingFeatureGroups(source.getReferencingFeatureGroups()); + target.setStartDate(source.getStartDate()); + target.setExpiryDate(source.getExpiryDate()); + target.setThresholdUnits(source.getThresholdUnits()); + target.setThresholdValue(source.getThresholdValue()); + target.setIncrements(source.getIncrements()); + target.setVersionUUID(source.getVersionUuId()); + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java index 87eea4ba1e..ed0e79d0a5 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; @@ -25,20 +24,20 @@ import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupRequestDto; -public class MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity - extends MappingBase<LicenseKeyGroupRequestDto, LicenseKeyGroupEntity> { - @Override - public void doMapping(LicenseKeyGroupRequestDto source, LicenseKeyGroupEntity target) { - target.setName(source.getName()); - target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); - target.setDescription(source.getDescription()); - target.setType(source.getType()); - target.setOperationalScope(new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther() - .applyMapping(source.getOperationalScope(), MultiChoiceOrOther.class)); - target.setStartDate(source.getStartDate()); - target.setExpiryDate(source.getExpiryDate()); - target.setThresholdUnits(source.getThresholdUnits()); - target.setThresholdValue(source.getThresholdValue()); - target.setIncrements(source.getIncrements()); - } +public class MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity extends MappingBase<LicenseKeyGroupRequestDto, LicenseKeyGroupEntity> { + + @Override + public void doMapping(LicenseKeyGroupRequestDto source, LicenseKeyGroupEntity target) { + target.setName(source.getName()); + target.setManufacturerReferenceNumber(source.getManufacturerReferenceNumber()); + target.setDescription(source.getDescription()); + target.setType(source.getType()); + target.setOperationalScope( + new MapMultiChoiceOrOtherDtoToMultiChoiceOrOther().applyMapping(source.getOperationalScope(), MultiChoiceOrOther.class)); + target.setStartDate(source.getStartDate()); + target.setExpiryDate(source.getExpiryDate()); + target.setThresholdUnits(source.getThresholdUnits()); + target.setThresholdValue(source.getThresholdValue()); + target.setIncrements(source.getIncrements()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java index ef4ae1ccdc..eb1a8a2def 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitCreationDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,16 +17,15 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; import org.openecomp.sdcrests.mapping.MappingBase; -public class MapLimitEntityToLimitCreationDto extends - MappingBase<LimitEntity, LimitCreationDto> { - @Override - public void doMapping(LimitEntity source, LimitCreationDto target) { - target.setLimitId(source.getId()); - } +public class MapLimitEntityToLimitCreationDto extends MappingBase<LimitEntity, LimitCreationDto> { + + @Override + public void doMapping(LimitEntity source, LimitCreationDto target) { + target.setLimitId(source.getId()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java index b17a0e08d4..030fcc1c91 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitEntityToLimitDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity; @@ -26,17 +25,16 @@ import org.openecomp.sdcrests.vendorlicense.types.LimitEntityDto; public class MapLimitEntityToLimitDto extends MappingBase<LimitEntity, LimitEntityDto> { - @Override - public void doMapping(LimitEntity source, LimitEntityDto target) { - target.setId(source.getId()); - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setMetric(source.getMetric()); - target.setAggregationFunction(source.getAggregationFunction() != null ? source - .getAggregationFunction().name() : null); - target.setTime(source.getTime()); - target.setType(source.getType() != null ? source.getType().name() : null); - target.setUnit(source.getUnit()); - target.setValue(source.getValue()); - } + @Override + public void doMapping(LimitEntity source, LimitEntityDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setMetric(source.getMetric()); + target.setAggregationFunction(source.getAggregationFunction() != null ? source.getAggregationFunction().name() : null); + target.setTime(source.getTime()); + target.setType(source.getType() != null ? source.getType().name() : null); + target.setUnit(source.getUnit()); + target.setValue(source.getValue()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java index 99f45bfc18..2de29c6e0c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapLimitRequestDtoToLimitEntity.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.common.errors.CoreException; @@ -32,11 +31,9 @@ import org.openecomp.sdc.vendorlicense.errors.VendorLicenseErrorCodes; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.LimitRequestDto; - public class MapLimitRequestDtoToLimitEntity extends MappingBase<LimitRequestDto, LimitEntity> { - private static final Logger logger = - LoggerFactory.getLogger(MapLimitRequestDtoToLimitEntity.class); + private static final Logger logger = LoggerFactory.getLogger(MapLimitRequestDtoToLimitEntity.class); @Override public void doMapping(LimitRequestDto source, LimitEntity target) { @@ -49,27 +46,22 @@ public class MapLimitRequestDtoToLimitEntity extends MappingBase<LimitRequestDto logger.error(exception.getMessage(), exception); throwInvalidValueError("type", VendorLicenseErrorCodes.LIMIT_INVALID_TYPE); } - try { - AggregationFunction function = source.getAggregationFunction() != null ? - AggregationFunction.valueOf(source.getAggregationFunction()) : null; + AggregationFunction function = + source.getAggregationFunction() != null ? AggregationFunction.valueOf(source.getAggregationFunction()) : null; target.setAggregationFunction(function); } catch (IllegalArgumentException exception) { logger.error(exception.getMessage(), exception); - throwInvalidValueError("aggregationFunction", - VendorLicenseErrorCodes.LIMIT_INVALID_AGGREGATIONFUNCTION); + throwInvalidValueError("aggregationFunction", VendorLicenseErrorCodes.LIMIT_INVALID_AGGREGATIONFUNCTION); } - target.setTime(source.getTime()); target.setMetric(source.getMetric()); target.setValue(source.getValue()); target.setUnit(source.getUnit()); - } private void throwInvalidValueError(String attribute, String vendorLicenseErrorCode) { - ErrorCode errorCode = LimitErrorBuilder.getInvalidValueErrorBuilder(attribute, - vendorLicenseErrorCode); + ErrorCode errorCode = LimitErrorBuilder.getInvalidValueErrorBuilder(attribute, vendorLicenseErrorCode); throw new CoreException(errorCode); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherDtoToMultiChoiceOrOther.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherDtoToMultiChoiceOrOther.java index 320bf67bdf..ad0aab26d1 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherDtoToMultiChoiceOrOther.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherDtoToMultiChoiceOrOther.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,20 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto; -public class MapMultiChoiceOrOtherDtoToMultiChoiceOrOther - extends MappingBase<MultiChoiceOrOtherDto, MultiChoiceOrOther> { +public class MapMultiChoiceOrOtherDtoToMultiChoiceOrOther extends MappingBase<MultiChoiceOrOtherDto, MultiChoiceOrOther> { - @Override - public void doMapping(MultiChoiceOrOtherDto source, MultiChoiceOrOther target) { - target.setChoices(source.getChoices()); - target.setOther(source.getOther()); - target.setResults(null); - } + @Override + public void doMapping(MultiChoiceOrOtherDto source, MultiChoiceOrOther target) { + target.setChoices(source.getChoices()); + target.setOther(source.getOther()); + target.setResults(null); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherToMultiChoiceOrOtherDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherToMultiChoiceOrOtherDto.java index 9649053fb4..93a2007897 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherToMultiChoiceOrOtherDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapMultiChoiceOrOtherToMultiChoiceOrOtherDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,19 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto; -public class MapMultiChoiceOrOtherToMultiChoiceOrOtherDto - extends MappingBase<MultiChoiceOrOther, MultiChoiceOrOtherDto> { +public class MapMultiChoiceOrOtherToMultiChoiceOrOtherDto extends MappingBase<MultiChoiceOrOther, MultiChoiceOrOtherDto> { - @Override - public void doMapping(MultiChoiceOrOther source, MultiChoiceOrOtherDto target) { - target.setChoices(source.getChoices()); - target.setOther(source.getOther()); - } + @Override + public void doMapping(MultiChoiceOrOther source, MultiChoiceOrOtherDto target) { + target.setChoices(source.getChoices()); + target.setOther(source.getOther()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelEntityToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelEntityToDto.java index 7bdde1d592..5b0bfb7d73 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelEntityToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelEntityToDto.java @@ -17,20 +17,19 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto; -public class MapVendorLicenseModelEntityToDto - extends MappingBase<VendorLicenseModelEntity, VendorLicenseModelEntityDto> { - @Override - public void doMapping(VendorLicenseModelEntity source, VendorLicenseModelEntityDto target) { - target.setId(source.getId()); - target.setVendorName(source.getVendorName()); - target.setDescription(source.getDescription()); - target.setIconRef(source.getIconRef()); - } +public class MapVendorLicenseModelEntityToDto extends MappingBase<VendorLicenseModelEntity, VendorLicenseModelEntityDto> { + + @Override + public void doMapping(VendorLicenseModelEntity source, VendorLicenseModelEntityDto target) { + target.setId(source.getId()); + target.setVendorName(source.getVendorName()); + target.setDescription(source.getDescription()); + target.setIconRef(source.getIconRef()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity.java index 593a4a37b0..2cbc81980a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/mapping/MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,19 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.mapping; import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelRequestDto; -public class MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity - extends MappingBase<VendorLicenseModelRequestDto, VendorLicenseModelEntity> { - @Override - public void doMapping(VendorLicenseModelRequestDto source, VendorLicenseModelEntity target) { - target.setVendorName(source.getVendorName()); - target.setDescription(source.getDescription()); - target.setIconRef(source.getIconRef()); - } +public class MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity extends MappingBase<VendorLicenseModelRequestDto, VendorLicenseModelEntity> { + + @Override + public void doMapping(VendorLicenseModelRequestDto source, VendorLicenseModelEntity target) { + target.setVendorName(source.getVendorName()); + target.setDescription(source.getDescription()); + target.setIconRef(source.getIconRef()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java index 544c1d7331..38e0a78154 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolLimitsImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,10 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.services; - +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; @@ -37,126 +38,89 @@ import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("entitlementPoolLimits") @Scope(value = "prototype") public class EntitlementPoolLimitsImpl implements EntitlementPoolLimits { - private VendorLicenseManager vendorLicenseManager = - VendorLicenseManagerFactory.getInstance().createInterface(); - - private static final String PARENT = "EntitlementPool"; - - @Override - public Response createLimit(LimitRequestDto request, - String vlmId, - String versionId, - String entitlementPoolId, - String user) { - Version version = new Version(versionId); - vendorLicenseManager - .getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); - - LimitEntity limitEntity = - new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); - limitEntity.setVendorLicenseModelId(vlmId); - limitEntity.setVersion(version); - limitEntity.setEpLkgId(entitlementPoolId); - limitEntity.setParent(PARENT); - LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity); - MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto(); - LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto.class); - - return Response.ok(createdLimitDto != null ? createdLimitDto : null).build(); - } - - @Override - public Response listLimits(String vlmId, String versionId, String entitlementPoolId, String - user) { - Version version = new Version(versionId); - vendorLicenseManager - .getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); - - Collection<LimitEntity> limits = - vendorLicenseManager.listLimits(vlmId, version, entitlementPoolId); - - GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>(); - MapLimitEntityToLimitDto outputMapper = - new MapLimitEntityToLimitDto(); - for (LimitEntity limit : limits) { - result.add(outputMapper.applyMapping(limit, LimitEntityDto.class)); + private static final String PARENT = "EntitlementPool"; + private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); + + @Override + public Response createLimit(LimitRequestDto request, String vlmId, String versionId, String entitlementPoolId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); + LimitEntity limitEntity = new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); + limitEntity.setVendorLicenseModelId(vlmId); + limitEntity.setVersion(version); + limitEntity.setEpLkgId(entitlementPoolId); + limitEntity.setParent(PARENT); + LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity); + MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto(); + LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto.class); + return Response.ok(createdLimitDto != null ? createdLimitDto : null).build(); } - return Response.ok(result).build(); - } - - @Override - public Response getLimit(String vlmId, String versionId, String entitlementPoolId, - String limitId, String user) { - Version version = new Version(versionId); - vendorLicenseManager - .getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); - LimitEntity limitInput = new LimitEntity(); - limitInput.setVendorLicenseModelId(vlmId); - limitInput.setVersion(version); - limitInput.setEpLkgId(entitlementPoolId); - limitInput.setId(limitId); - LimitEntity limit = vendorLicenseManager.getLimit(limitInput); - - LimitEntityDto entitlementPoolEntityDto = limit == null ? null : - new MapLimitEntityToLimitDto().applyMapping(limit, LimitEntityDto.class); - return Response.ok(entitlementPoolEntityDto).build(); - } - @Override - public Response updateLimit(LimitRequestDto request, - String vlmId, - String versionId, - String entitlementPoolId, - String limitId, - String user) { - Version version = new Version(versionId); - vendorLicenseManager - .getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); - - LimitEntity limitEntity = - new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); - limitEntity.setVendorLicenseModelId(vlmId); - limitEntity.setVersion(version); - limitEntity.setEpLkgId(entitlementPoolId); - limitEntity.setId(limitId); - limitEntity.setParent(PARENT); - - vendorLicenseManager.updateLimit(limitEntity); - return Response.ok().build(); - } + @Override + public Response listLimits(String vlmId, String versionId, String entitlementPoolId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); + Collection<LimitEntity> limits = vendorLicenseManager.listLimits(vlmId, version, entitlementPoolId); + GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>(); + MapLimitEntityToLimitDto outputMapper = new MapLimitEntityToLimitDto(); + for (LimitEntity limit : limits) { + result.add(outputMapper.applyMapping(limit, LimitEntityDto.class)); + } + return Response.ok(result).build(); + } - /** - * Delete entitlement pool. - * - * @param vlmId the vlm id - * @param entitlementPoolId the entitlement pool id - * @param limitId the limitId - * @param user the user - * @return the response - */ - public Response deleteLimit(String vlmId, String versionId, String entitlementPoolId, - String limitId, String user) { - Version version = new Version(versionId); - vendorLicenseManager.getEntitlementPool( - new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); + @Override + public Response getLimit(String vlmId, String versionId, String entitlementPoolId, String limitId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); + LimitEntity limitInput = new LimitEntity(); + limitInput.setVendorLicenseModelId(vlmId); + limitInput.setVersion(version); + limitInput.setEpLkgId(entitlementPoolId); + limitInput.setId(limitId); + LimitEntity limit = vendorLicenseManager.getLimit(limitInput); + LimitEntityDto entitlementPoolEntityDto = limit == null ? null : new MapLimitEntityToLimitDto().applyMapping(limit, LimitEntityDto.class); + return Response.ok(entitlementPoolEntityDto).build(); + } - LimitEntity limitInput = new LimitEntity(); - limitInput.setVendorLicenseModelId(vlmId); - limitInput.setVersion(version); - limitInput.setEpLkgId(entitlementPoolId); - limitInput.setId(limitId); - limitInput.setParent(PARENT); + @Override + public Response updateLimit(LimitRequestDto request, String vlmId, String versionId, String entitlementPoolId, String limitId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); + LimitEntity limitEntity = new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); + limitEntity.setVendorLicenseModelId(vlmId); + limitEntity.setVersion(version); + limitEntity.setEpLkgId(entitlementPoolId); + limitEntity.setId(limitId); + limitEntity.setParent(PARENT); + vendorLicenseManager.updateLimit(limitEntity); + return Response.ok().build(); + } - vendorLicenseManager.deleteLimit(limitInput); - return Response.ok().build(); - } + /** + * Delete entitlement pool. + * + * @param vlmId the vlm id + * @param entitlementPoolId the entitlement pool id + * @param limitId the limitId + * @param user the user + * @return the response + */ + public Response deleteLimit(String vlmId, String versionId, String entitlementPoolId, String limitId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getEntitlementPool(new EntitlementPoolEntity(vlmId, version, entitlementPoolId)); + LimitEntity limitInput = new LimitEntity(); + limitInput.setVendorLicenseModelId(vlmId); + limitInput.setVersion(version); + limitInput.setEpLkgId(entitlementPoolId); + limitInput.setId(limitId); + limitInput.setParent(PARENT); + vendorLicenseManager.deleteLimit(limitInput); + return Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java index 83519198b7..bff8c7a449 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/EntitlementPoolsImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.services; import java.util.Comparator; @@ -42,115 +41,97 @@ import org.springframework.stereotype.Service; @Service("entitlementPools") @Scope(value = "prototype") public class EntitlementPoolsImpl implements EntitlementPools { - private VendorLicenseManager vendorLicenseManager = - VendorLicenseManagerFactory.getInstance().createInterface(); - - /** - * List entitlement pools response. - * - * @param vlmId the vlm id - * @param versionId the version - * @param user the user - * @return the response - */ - public Response listEntitlementPools(String vlmId, String versionId, String user) { - MapEntitlementPoolEntityToEntitlementPoolEntityDto outputMapper = - new MapEntitlementPoolEntityToEntitlementPoolEntityDto(); + private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); + /** + * List entitlement pools response. + * + * @param vlmId the vlm id + * @param versionId the version + * @param user the user + * @return the response + */ + public Response listEntitlementPools(String vlmId, String versionId, String user) { + MapEntitlementPoolEntityToEntitlementPoolEntityDto outputMapper = new MapEntitlementPoolEntityToEntitlementPoolEntityDto(); GenericCollectionWrapper<EntitlementPoolEntityDto> result = new GenericCollectionWrapper<>( - vendorLicenseManager.listEntitlementPools(vlmId, new Version(versionId)).stream() - .sorted(Comparator.comparing(EntitlementPoolEntity::getName)) - .map(item -> outputMapper.applyMapping(item, EntitlementPoolEntityDto.class)) - .collect(Collectors.toList())); - + vendorLicenseManager.listEntitlementPools(vlmId, new Version(versionId)).stream() + .sorted(Comparator.comparing(EntitlementPoolEntity::getName)) + .map(item -> outputMapper.applyMapping(item, EntitlementPoolEntityDto.class)).collect(Collectors.toList())); return Response.ok(result).build(); } - /** - * Create entitlement pool response. - * - * @param request the request - * @param vlmId the vlm id - * @param user the user - * @return the response - */ - public Response createEntitlementPool(EntitlementPoolRequestDto request, String vlmId, - String versionId, String user) { - EntitlementPoolEntity entitlementPoolEntity = - new MapEntitlementPoolRequestDtoToEntitlementPoolEntity() + /** + * Create entitlement pool response. + * + * @param request the request + * @param vlmId the vlm id + * @param user the user + * @return the response + */ + public Response createEntitlementPool(EntitlementPoolRequestDto request, String vlmId, String versionId, String user) { + EntitlementPoolEntity entitlementPoolEntity = new MapEntitlementPoolRequestDtoToEntitlementPoolEntity() .applyMapping(request, EntitlementPoolEntity.class); - entitlementPoolEntity.setVendorLicenseModelId(vlmId); - entitlementPoolEntity.setVersion(new Version(versionId)); - - EntitlementPoolEntity createdEntitlementPool = - vendorLicenseManager.createEntitlementPool(entitlementPoolEntity); - StringWrapperResponse result = - createdEntitlementPool != null ? new StringWrapperResponse(createdEntitlementPool.getId()) - : null; - return Response.ok(result).build(); - } + entitlementPoolEntity.setVendorLicenseModelId(vlmId); + entitlementPoolEntity.setVersion(new Version(versionId)); + EntitlementPoolEntity createdEntitlementPool = vendorLicenseManager.createEntitlementPool(entitlementPoolEntity); + StringWrapperResponse result = createdEntitlementPool != null ? new StringWrapperResponse(createdEntitlementPool.getId()) : null; + return Response.ok(result).build(); + } - /** - * Update entitlement pool response. - * - * @param request the request - * @param vlmId the vlm id - * @param entitlementPoolId the entitlement pool id - * @param user the user - * @return the response - */ - public Response updateEntitlementPool(EntitlementPoolRequestDto request, String vlmId, - String versionId, String entitlementPoolId, String user) { - EntitlementPoolEntity entitlementPoolEntity = - new MapEntitlementPoolRequestDtoToEntitlementPoolEntity() + /** + * Update entitlement pool response. + * + * @param request the request + * @param vlmId the vlm id + * @param entitlementPoolId the entitlement pool id + * @param user the user + * @return the response + */ + public Response updateEntitlementPool(EntitlementPoolRequestDto request, String vlmId, String versionId, String entitlementPoolId, String user) { + EntitlementPoolEntity entitlementPoolEntity = new MapEntitlementPoolRequestDtoToEntitlementPoolEntity() .applyMapping(request, EntitlementPoolEntity.class); - entitlementPoolEntity.setVendorLicenseModelId(vlmId); - entitlementPoolEntity.setVersion(new Version(versionId)); - entitlementPoolEntity.setId(entitlementPoolId); - - vendorLicenseManager.updateEntitlementPool(entitlementPoolEntity); - return Response.ok().build(); - } - - /** - * Gets entitlement pool. - * - * @param vlmId the vlm id - * @param versionId the version id - * @param entitlementPoolId the entitlement pool id - * @param user the user - * @return the entitlement pool - */ - public Response getEntitlementPool(String vlmId, String versionId, String entitlementPoolId, - String user) { - EntitlementPoolEntity epInput = new EntitlementPoolEntity(); - epInput.setVendorLicenseModelId(vlmId); - epInput.setVersion(new Version(versionId)); - epInput.setId(entitlementPoolId); - EntitlementPoolEntity entitlementPool = vendorLicenseManager.getEntitlementPool(epInput); + entitlementPoolEntity.setVendorLicenseModelId(vlmId); + entitlementPoolEntity.setVersion(new Version(versionId)); + entitlementPoolEntity.setId(entitlementPoolId); + vendorLicenseManager.updateEntitlementPool(entitlementPoolEntity); + return Response.ok().build(); + } - EntitlementPoolEntityDto entitlementPoolEntityDto = entitlementPool == null ? null : - new MapEntitlementPoolEntityToEntitlementPoolEntityDto() - .applyMapping(entitlementPool, EntitlementPoolEntityDto.class); - return Response.ok(entitlementPoolEntityDto).build(); - } + /** + * Gets entitlement pool. + * + * @param vlmId the vlm id + * @param versionId the version id + * @param entitlementPoolId the entitlement pool id + * @param user the user + * @return the entitlement pool + */ + public Response getEntitlementPool(String vlmId, String versionId, String entitlementPoolId, String user) { + EntitlementPoolEntity epInput = new EntitlementPoolEntity(); + epInput.setVendorLicenseModelId(vlmId); + epInput.setVersion(new Version(versionId)); + epInput.setId(entitlementPoolId); + EntitlementPoolEntity entitlementPool = vendorLicenseManager.getEntitlementPool(epInput); + EntitlementPoolEntityDto entitlementPoolEntityDto = entitlementPool == null ? null + : new MapEntitlementPoolEntityToEntitlementPoolEntityDto().applyMapping(entitlementPool, EntitlementPoolEntityDto.class); + return Response.ok(entitlementPoolEntityDto).build(); + } - /** - * Delete entitlement pool response. - * - * @param vlmId the vlm id - * @param entitlementPoolId the entitlement pool id - * @param user the user - * @return the response - */ - public Response deleteEntitlementPool(String vlmId, String versionId, String entitlementPoolId, - String user) { - EntitlementPoolEntity epInput = new EntitlementPoolEntity(); - epInput.setVendorLicenseModelId(vlmId); - epInput.setId(entitlementPoolId); - epInput.setVersion(new Version(versionId)); - vendorLicenseManager.deleteEntitlementPool(epInput); - return Response.ok().build(); - } + /** + * Delete entitlement pool response. + * + * @param vlmId the vlm id + * @param entitlementPoolId the entitlement pool id + * @param user the user + * @return the response + */ + public Response deleteEntitlementPool(String vlmId, String versionId, String entitlementPoolId, String user) { + EntitlementPoolEntity epInput = new EntitlementPoolEntity(); + epInput.setVendorLicenseModelId(vlmId); + epInput.setId(entitlementPoolId); + epInput.setVersion(new Version(versionId)); + vendorLicenseManager.deleteEntitlementPool(epInput); + return Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java index 4ea35d321d..a945784213 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/FeatureGroupsImpl.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.services; import java.util.Comparator; @@ -54,104 +53,75 @@ import org.springframework.stereotype.Service; @Scope(value = "prototype") public class FeatureGroupsImpl implements FeatureGroups { - private VendorLicenseManager vendorLicenseManager = - VendorLicenseManagerFactory.getInstance().createInterface(); + private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); @Override public Response listFeatureGroups(String vlmId, String versionId, String user) { - - MapFeatureGroupEntityToFeatureGroupDescriptorDto outputMapper = - new MapFeatureGroupEntityToFeatureGroupDescriptorDto(); - + MapFeatureGroupEntityToFeatureGroupDescriptorDto outputMapper = new MapFeatureGroupEntityToFeatureGroupDescriptorDto(); GenericCollectionWrapper<FeatureGroupEntityDto> results = new GenericCollectionWrapper<>( - vendorLicenseManager.listFeatureGroups(vlmId, new Version(versionId)).stream() - .sorted(Comparator.comparing(FeatureGroupEntity::getName)) - .map(fg -> getFeatureGroupEntityDto(outputMapper,fg)).collect(Collectors.toList())); - + vendorLicenseManager.listFeatureGroups(vlmId, new Version(versionId)).stream().sorted(Comparator.comparing(FeatureGroupEntity::getName)) + .map(fg -> getFeatureGroupEntityDto(outputMapper, fg)).collect(Collectors.toList())); return Response.ok(results).build(); } @Override - public Response createFeatureGroup(FeatureGroupRequestDto request, String vlmId, String versionId, - String user) { + public Response createFeatureGroup(FeatureGroupRequestDto request, String vlmId, String versionId, String user) { FeatureGroupEntity featureGroupEntity = new MapFeatureGroupDescriptorDtoToFeatureGroupEntity() - .applyMapping(request, FeatureGroupEntity.class); + .applyMapping(request, FeatureGroupEntity.class); featureGroupEntity.setVendorLicenseModelId(vlmId); featureGroupEntity.setVersion(new Version(versionId)); featureGroupEntity.setLicenseKeyGroupIds(request.getAddedLicenseKeyGroupsIds()); featureGroupEntity.setEntitlementPoolIds(request.getAddedEntitlementPoolsIds()); - - FeatureGroupEntity createdFeatureGroup = - vendorLicenseManager.createFeatureGroup(featureGroupEntity); - - StringWrapperResponse result = - createdFeatureGroup != null ? new StringWrapperResponse(createdFeatureGroup.getId()) : null; + FeatureGroupEntity createdFeatureGroup = vendorLicenseManager.createFeatureGroup(featureGroupEntity); + StringWrapperResponse result = createdFeatureGroup != null ? new StringWrapperResponse(createdFeatureGroup.getId()) : null; return Response.ok(result).build(); } @Override - public Response updateFeatureGroup(FeatureGroupUpdateRequestDto request, String vlmId, - String versionId, String featureGroupId, String user) { + public Response updateFeatureGroup(FeatureGroupUpdateRequestDto request, String vlmId, String versionId, String featureGroupId, String user) { FeatureGroupEntity featureGroupEntity = new MapFeatureGroupDescriptorDtoToFeatureGroupEntity() - .applyMapping(request, FeatureGroupEntity.class); + .applyMapping(request, FeatureGroupEntity.class); featureGroupEntity.setVendorLicenseModelId(vlmId); featureGroupEntity.setVersion(new Version(versionId)); featureGroupEntity.setId(featureGroupId); - - vendorLicenseManager - .updateFeatureGroup(featureGroupEntity, request.getAddedLicenseKeyGroupsIds(), - request.getRemovedLicenseKeyGroupsIds(), request.getAddedEntitlementPoolsIds(), - request.getRemovedEntitlementPoolsIds()); + vendorLicenseManager.updateFeatureGroup(featureGroupEntity, request.getAddedLicenseKeyGroupsIds(), request.getRemovedLicenseKeyGroupsIds(), + request.getAddedEntitlementPoolsIds(), request.getRemovedEntitlementPoolsIds()); return Response.ok().build(); } @Override - public Response getFeatureGroup(String vlmId, String versionId, String featureGroupId, - String user) { + public Response getFeatureGroup(String vlmId, String versionId, String featureGroupId, String user) { FeatureGroupEntity fgInput = new FeatureGroupEntity(); fgInput.setVendorLicenseModelId(vlmId); fgInput.setVersion(new Version(versionId)); fgInput.setId(featureGroupId); FeatureGroupModel featureGroupModel = vendorLicenseManager.getFeatureGroupModel(fgInput); - if (featureGroupModel == null) { return Response.ok().build(); } - FeatureGroupModelDto fgmDto = new FeatureGroupModelDto(); fgmDto.setId(featureGroupModel.getFeatureGroup().getId()); - fgmDto.setReferencingLicenseAgreements( - featureGroupModel.getFeatureGroup().getReferencingLicenseAgreements()); - new MapFeatureGroupEntityToFeatureGroupDescriptorDto() - .doMapping(featureGroupModel.getFeatureGroup(), fgmDto); - + fgmDto.setReferencingLicenseAgreements(featureGroupModel.getFeatureGroup().getReferencingLicenseAgreements()); + new MapFeatureGroupEntityToFeatureGroupDescriptorDto().doMapping(featureGroupModel.getFeatureGroup(), fgmDto); if (!CollectionUtils.isEmpty(featureGroupModel.getLicenseKeyGroups())) { fgmDto.setLicenseKeyGroups(new HashSet<>()); - - MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto lkgMapper = - new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(); + MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto lkgMapper = new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(); for (LicenseKeyGroupEntity lkg : featureGroupModel.getLicenseKeyGroups()) { - fgmDto.getLicenseKeyGroups() - .add(lkgMapper.applyMapping(lkg, LicenseKeyGroupEntityDto.class)); + fgmDto.getLicenseKeyGroups().add(lkgMapper.applyMapping(lkg, LicenseKeyGroupEntityDto.class)); } } - if (!CollectionUtils.isEmpty(featureGroupModel.getEntitlementPools())) { fgmDto.setEntitlementPools(new HashSet<>()); - - MapEntitlementPoolEntityToEntitlementPoolEntityDto epMapper = - new MapEntitlementPoolEntityToEntitlementPoolEntityDto(); + MapEntitlementPoolEntityToEntitlementPoolEntityDto epMapper = new MapEntitlementPoolEntityToEntitlementPoolEntityDto(); for (EntitlementPoolEntity ep : featureGroupModel.getEntitlementPools()) { fgmDto.getEntitlementPools().add(epMapper.applyMapping(ep, EntitlementPoolEntityDto.class)); - } } return Response.ok(fgmDto).build(); } @Override - public Response deleteFeatureGroup(String vlmId, String versionId, String featureGroupId, - String user) { + public Response deleteFeatureGroup(String vlmId, String versionId, String featureGroupId, String user) { FeatureGroupEntity fgInput = new FeatureGroupEntity(); fgInput.setVendorLicenseModelId(vlmId); fgInput.setVersion(new Version(versionId)); @@ -160,7 +130,7 @@ public class FeatureGroupsImpl implements FeatureGroups { return Response.ok().build(); } - private FeatureGroupEntityDto getFeatureGroupEntityDto(MapFeatureGroupEntityToFeatureGroupDescriptorDto mapper,FeatureGroupEntity fg) { + private FeatureGroupEntityDto getFeatureGroupEntityDto(MapFeatureGroupEntityToFeatureGroupDescriptorDto mapper, FeatureGroupEntity fg) { FeatureGroupEntityDto fgDto = new FeatureGroupEntityDto(); fgDto.setId(fg.getId()); fgDto.setLicenseKeyGroupsIds(fg.getLicenseKeyGroupIds()); @@ -169,5 +139,4 @@ public class FeatureGroupsImpl implements FeatureGroups { mapper.doMapping(fg, fgDto); return fgDto; } - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java index 7c0539931b..fb67b237f0 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseAgreementsImpl.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.services; import java.util.Comparator; @@ -51,8 +50,7 @@ import org.springframework.stereotype.Service; @Scope(value = "prototype") public class LicenseAgreementsImpl implements LicenseAgreements { - private VendorLicenseManager vendorLicenseManager = - VendorLicenseManagerFactory.getInstance().createInterface(); + private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); /** * List license agreements response. @@ -63,20 +61,14 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * @return the response */ public Response listLicenseAgreements(String vlmId, String versionId, String user) { - - MapLicenseAgreementEntityToLicenseAgreementDescriptorDto outputMapper = - new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto(); - + MapLicenseAgreementEntityToLicenseAgreementDescriptorDto outputMapper = new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto(); GenericCollectionWrapper<LicenseAgreementEntityDto> results = new GenericCollectionWrapper<>( - vendorLicenseManager.listLicenseAgreements(vlmId, new Version(versionId)).stream() - .sorted(Comparator.comparing(LicenseAgreementEntity::getName)) - .map(lae -> getLicenseAgreementEntityDto(outputMapper, lae)) - .collect(Collectors.toList())); - + vendorLicenseManager.listLicenseAgreements(vlmId, new Version(versionId)).stream() + .sorted(Comparator.comparing(LicenseAgreementEntity::getName)).map(lae -> getLicenseAgreementEntityDto(outputMapper, lae)) + .collect(Collectors.toList())); return Response.ok(results).build(); } - /** * Create license agreement response. * @@ -85,20 +77,14 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * @param user the user * @return the response */ - public Response createLicenseAgreement(LicenseAgreementRequestDto request, String vlmId, - String versionId, String user) { - LicenseAgreementEntity licenseAgreementEntity = - new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity() - .applyMapping(request, LicenseAgreementEntity.class); + public Response createLicenseAgreement(LicenseAgreementRequestDto request, String vlmId, String versionId, String user) { + LicenseAgreementEntity licenseAgreementEntity = new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity() + .applyMapping(request, LicenseAgreementEntity.class); licenseAgreementEntity.setVendorLicenseModelId(vlmId); licenseAgreementEntity.setVersion(new Version(versionId)); licenseAgreementEntity.setFeatureGroupIds(request.getAddedFeatureGroupsIds()); - - LicenseAgreementEntity createdLicenseAgreement = - vendorLicenseManager.createLicenseAgreement(licenseAgreementEntity); - StringWrapperResponse result = - createdLicenseAgreement != null ? new StringWrapperResponse(createdLicenseAgreement.getId()) - : null; + LicenseAgreementEntity createdLicenseAgreement = vendorLicenseManager.createLicenseAgreement(licenseAgreementEntity); + StringWrapperResponse result = createdLicenseAgreement != null ? new StringWrapperResponse(createdLicenseAgreement.getId()) : null; return Response.ok(result).build(); } @@ -111,18 +97,14 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * @param user the user * @return the response */ - public Response updateLicenseAgreement(LicenseAgreementUpdateRequestDto request, String vlmId, - String versionId, String licenseAgreementId, String user) { - LicenseAgreementEntity licenseAgreementEntity = - new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity() - .applyMapping(request, LicenseAgreementEntity.class); + public Response updateLicenseAgreement(LicenseAgreementUpdateRequestDto request, String vlmId, String versionId, String licenseAgreementId, + String user) { + LicenseAgreementEntity licenseAgreementEntity = new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity() + .applyMapping(request, LicenseAgreementEntity.class); licenseAgreementEntity.setVendorLicenseModelId(vlmId); licenseAgreementEntity.setVersion(new Version(versionId)); licenseAgreementEntity.setId(licenseAgreementId); - - vendorLicenseManager - .updateLicenseAgreement(licenseAgreementEntity, request.getAddedFeatureGroupsIds(), - request.getRemovedFeatureGroupsIds()); + vendorLicenseManager.updateLicenseAgreement(licenseAgreementEntity, request.getAddedFeatureGroupsIds(), request.getRemovedFeatureGroupsIds()); return Response.ok().build(); } @@ -135,32 +117,24 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * @param user the user * @return the license agreement */ - public Response getLicenseAgreement(String vlmId, String versionId, String licenseAgreementId, - String user) { + public Response getLicenseAgreement(String vlmId, String versionId, String licenseAgreementId, String user) { LicenseAgreementModel licenseAgreementModel = vendorLicenseManager - .getLicenseAgreementModel(vlmId, new Version(versionId), licenseAgreementId); - + .getLicenseAgreementModel(vlmId, new Version(versionId), licenseAgreementId); if (licenseAgreementModel == null) { return Response.ok().build(); } - LicenseAgreementModelDto lamDto = new LicenseAgreementModelDto(); lamDto.setId(licenseAgreementModel.getLicenseAgreement().getId()); - new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto() - .doMapping(licenseAgreementModel.getLicenseAgreement(), lamDto); - + new MapLicenseAgreementEntityToLicenseAgreementDescriptorDto().doMapping(licenseAgreementModel.getLicenseAgreement(), lamDto); if (!CollectionUtils.isEmpty(licenseAgreementModel.getFeatureGroups())) { lamDto.setFeatureGroups(new HashSet<>()); - - MapFeatureGroupEntityToFeatureGroupDescriptorDto fgMapper = - new MapFeatureGroupEntityToFeatureGroupDescriptorDto(); + MapFeatureGroupEntityToFeatureGroupDescriptorDto fgMapper = new MapFeatureGroupEntityToFeatureGroupDescriptorDto(); for (FeatureGroupEntity fg : licenseAgreementModel.getFeatureGroups()) { FeatureGroupEntityDto fgeDto = new FeatureGroupEntityDto(); fgeDto.setId(fg.getId()); fgeDto.setEntitlementPoolsIds(fg.getEntitlementPoolIds()); fgeDto.setLicenseKeyGroupsIds(fg.getLicenseKeyGroupIds()); fgMapper.doMapping(fg, fgeDto); - lamDto.getFeatureGroups().add(fgeDto); } } @@ -176,14 +150,13 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * @param user the user * @return the response */ - public Response deleteLicenseAgreement(String vlmId, String versionId, String licenseAgreementId, - String user) { + public Response deleteLicenseAgreement(String vlmId, String versionId, String licenseAgreementId, String user) { vendorLicenseManager.deleteLicenseAgreement(vlmId, new Version(versionId), licenseAgreementId); return Response.ok().build(); } - private LicenseAgreementEntityDto getLicenseAgreementEntityDto( - MapLicenseAgreementEntityToLicenseAgreementDescriptorDto mapper, LicenseAgreementEntity lae) { + private LicenseAgreementEntityDto getLicenseAgreementEntityDto(MapLicenseAgreementEntityToLicenseAgreementDescriptorDto mapper, + LicenseAgreementEntity lae) { LicenseAgreementEntityDto laeDto = new LicenseAgreementEntityDto(); laeDto.setId(lae.getId()); laeDto.setFeatureGroupsIds(lae.getFeatureGroupIds()); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java index 14491b0e6a..7d4f1f7679 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupLimitsImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.services; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; import org.openecomp.sdc.vendorlicense.VendorLicenseManagerFactory; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; @@ -36,126 +38,89 @@ import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("licenseKeyGroupLimits") @Scope(value = "prototype") public class LicenseKeyGroupLimitsImpl implements LicenseKeyGroupLimits { - private VendorLicenseManager vendorLicenseManager = - VendorLicenseManagerFactory.getInstance().createInterface(); - - private static final String PARENT = "LicenseKeyGroup"; - - - @Override - public Response createLimit(LimitRequestDto request, - String vlmId, - String versionId, - String licenseKeyGroupId, - String user) { - Version version = new Version(versionId); - vendorLicenseManager.getLicenseKeyGroup( - new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); - - LimitEntity limitEntity = - new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); - limitEntity.setVendorLicenseModelId(vlmId); - limitEntity.setVersion(version); - limitEntity.setEpLkgId(licenseKeyGroupId); - limitEntity.setParent(PARENT); - LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity); - MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto(); - LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto.class); - return Response.ok(createdLimitDto != null ? createdLimitDto : null).build(); - } - - @Override - public Response listLimits(String vlmId, String versionId, String licenseKeyGroupId, - String user) { - Version version = new Version(versionId); - vendorLicenseManager - .getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); - - Collection<LimitEntity> limits = - vendorLicenseManager.listLimits(vlmId, version, licenseKeyGroupId); - - GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>(); - MapLimitEntityToLimitDto outputMapper = - new MapLimitEntityToLimitDto(); - for (LimitEntity limit : limits) { - result.add(outputMapper.applyMapping(limit, LimitEntityDto.class)); + private static final String PARENT = "LicenseKeyGroup"; + private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); + + @Override + public Response createLimit(LimitRequestDto request, String vlmId, String versionId, String licenseKeyGroupId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); + LimitEntity limitEntity = new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); + limitEntity.setVendorLicenseModelId(vlmId); + limitEntity.setVersion(version); + limitEntity.setEpLkgId(licenseKeyGroupId); + limitEntity.setParent(PARENT); + LimitEntity createdLimit = vendorLicenseManager.createLimit(limitEntity); + MapLimitEntityToLimitCreationDto mapper = new MapLimitEntityToLimitCreationDto(); + LimitCreationDto createdLimitDto = mapper.applyMapping(createdLimit, LimitCreationDto.class); + return Response.ok(createdLimitDto != null ? createdLimitDto : null).build(); } - return Response.ok(result).build(); - } - - @Override - public Response updateLimit(LimitRequestDto request, - String vlmId, - String versionId, - String licenseKeyGroupId, - String limitId, - String user) { - Version version = new Version(versionId); - vendorLicenseManager - .getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); - - LimitEntity limitEntity = - new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); - limitEntity.setVendorLicenseModelId(vlmId); - limitEntity.setVersion(version); - limitEntity.setEpLkgId(licenseKeyGroupId); - limitEntity.setId(limitId); - limitEntity.setParent(PARENT); - - vendorLicenseManager.updateLimit(limitEntity); - return Response.ok().build(); - } - /** - * Delete License Key Group. - * - * @param vlmId the vlm id - * @param licenseKeyGroupId the license Key Group id - * @param limitId the limitId - * @param user the user - * @return the response - */ - public Response deleteLimit(String vlmId, String versionId, String licenseKeyGroupId, - String limitId, String user) { - Version version = new Version(versionId); - vendorLicenseManager - .getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); - - LimitEntity limitInput = new LimitEntity(); - limitInput.setVendorLicenseModelId(vlmId); - limitInput.setVersion(version); - limitInput.setEpLkgId(licenseKeyGroupId); - limitInput.setId(limitId); - limitInput.setParent(PARENT); + @Override + public Response listLimits(String vlmId, String versionId, String licenseKeyGroupId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); + Collection<LimitEntity> limits = vendorLicenseManager.listLimits(vlmId, version, licenseKeyGroupId); + GenericCollectionWrapper<LimitEntityDto> result = new GenericCollectionWrapper<>(); + MapLimitEntityToLimitDto outputMapper = new MapLimitEntityToLimitDto(); + for (LimitEntity limit : limits) { + result.add(outputMapper.applyMapping(limit, LimitEntityDto.class)); + } + return Response.ok(result).build(); + } - vendorLicenseManager.deleteLimit(limitInput); - return Response.ok().build(); - } + @Override + public Response updateLimit(LimitRequestDto request, String vlmId, String versionId, String licenseKeyGroupId, String limitId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); + LimitEntity limitEntity = new MapLimitRequestDtoToLimitEntity().applyMapping(request, LimitEntity.class); + limitEntity.setVendorLicenseModelId(vlmId); + limitEntity.setVersion(version); + limitEntity.setEpLkgId(licenseKeyGroupId); + limitEntity.setId(limitId); + limitEntity.setParent(PARENT); + vendorLicenseManager.updateLimit(limitEntity); + return Response.ok().build(); + } - @Override - public Response getLimit(String vlmId, String versionId, String licenseKeyGroupId, - String limitId, String user) { - Version version = new Version(versionId); - vendorLicenseManager - .getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); - LimitEntity limitInput = new LimitEntity(); - limitInput.setVendorLicenseModelId(vlmId); - limitInput.setVersion(version); - limitInput.setEpLkgId(licenseKeyGroupId); - limitInput.setId(limitId); - LimitEntity limit = vendorLicenseManager.getLimit(limitInput); + /** + * Delete License Key Group. + * + * @param vlmId the vlm id + * @param licenseKeyGroupId the license Key Group id + * @param limitId the limitId + * @param user the user + * @return the response + */ + public Response deleteLimit(String vlmId, String versionId, String licenseKeyGroupId, String limitId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); + LimitEntity limitInput = new LimitEntity(); + limitInput.setVendorLicenseModelId(vlmId); + limitInput.setVersion(version); + limitInput.setEpLkgId(licenseKeyGroupId); + limitInput.setId(limitId); + limitInput.setParent(PARENT); + vendorLicenseManager.deleteLimit(limitInput); + return Response.ok().build(); + } - LimitEntityDto entitlementPoolEntityDto = limit == null ? null - : new MapLimitEntityToLimitDto().applyMapping(limit, LimitEntityDto.class); - return Response.ok(entitlementPoolEntityDto).build(); - } + @Override + public Response getLimit(String vlmId, String versionId, String licenseKeyGroupId, String limitId, String user) { + Version version = new Version(versionId); + vendorLicenseManager.getLicenseKeyGroup(new LicenseKeyGroupEntity(vlmId, version, licenseKeyGroupId)); + LimitEntity limitInput = new LimitEntity(); + limitInput.setVendorLicenseModelId(vlmId); + limitInput.setVersion(version); + limitInput.setEpLkgId(licenseKeyGroupId); + limitInput.setId(limitId); + LimitEntity limit = vendorLicenseManager.getLimit(limitInput); + LimitEntityDto entitlementPoolEntityDto = limit == null ? null : new MapLimitEntityToLimitDto().applyMapping(limit, LimitEntityDto.class); + return Response.ok(entitlementPoolEntityDto).build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java index 3edee02080..f7ddc25eba 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/LicenseKeyGroupsImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,12 +17,10 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.rest.services; import java.util.Comparator; import java.util.stream.Collectors; -import java.util.stream.Stream; import javax.inject.Named; import javax.ws.rs.core.Response; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; @@ -45,116 +43,97 @@ import org.springframework.validation.annotation.Validated; @Scope(value = "prototype") @Validated public class LicenseKeyGroupsImpl implements LicenseKeyGroups { - private VendorLicenseManager vendorLicenseManager = - VendorLicenseManagerFactory.getInstance().createInterface(); - - /** - * List license key groups response. - * - * @param vlmId the vlm id - * @param versionId the version - * @param user the user - * @return the response - */ - public Response listLicenseKeyGroups(String vlmId, String versionId, String user) { - MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto outputMapper = - new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(); + private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); - GenericCollectionWrapper<LicenseKeyGroupEntityDto> result = new GenericCollectionWrapper<>( + /** + * List license key groups response. + * + * @param vlmId the vlm id + * @param versionId the version + * @param user the user + * @return the response + */ + public Response listLicenseKeyGroups(String vlmId, String versionId, String user) { + MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto outputMapper = new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto(); + GenericCollectionWrapper<LicenseKeyGroupEntityDto> result = new GenericCollectionWrapper<>( vendorLicenseManager.listLicenseKeyGroups(vlmId, new Version(versionId)).stream() - .sorted(Comparator.comparing(LicenseKeyGroupEntity::getName)) - .map(item -> outputMapper.applyMapping(item, LicenseKeyGroupEntityDto.class)) - .collect(Collectors.toList())); - - return Response.ok(result).build(); - } + .sorted(Comparator.comparing(LicenseKeyGroupEntity::getName)) + .map(item -> outputMapper.applyMapping(item, LicenseKeyGroupEntityDto.class)).collect(Collectors.toList())); + return Response.ok(result).build(); + } - /** - * Create license key group response. - * - * @param request the request - * @param vlmId the vlm id - * @param user the user - * @return the response - */ - public Response createLicenseKeyGroup(LicenseKeyGroupRequestDto request, String vlmId, - String versionId, String user) { - LicenseKeyGroupEntity licenseKeyGroupEntity = - new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity() + /** + * Create license key group response. + * + * @param request the request + * @param vlmId the vlm id + * @param user the user + * @return the response + */ + public Response createLicenseKeyGroup(LicenseKeyGroupRequestDto request, String vlmId, String versionId, String user) { + LicenseKeyGroupEntity licenseKeyGroupEntity = new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity() .applyMapping(request, LicenseKeyGroupEntity.class); - licenseKeyGroupEntity.setVendorLicenseModelId(vlmId); - licenseKeyGroupEntity.setVersion(new Version(versionId)); + licenseKeyGroupEntity.setVendorLicenseModelId(vlmId); + licenseKeyGroupEntity.setVersion(new Version(versionId)); + LicenseKeyGroupEntity createdLicenseKeyGroup = vendorLicenseManager.createLicenseKeyGroup(licenseKeyGroupEntity); + StringWrapperResponse result = createdLicenseKeyGroup != null ? new StringWrapperResponse(createdLicenseKeyGroup.getId()) : null; + return Response.ok(result).build(); + } - LicenseKeyGroupEntity createdLicenseKeyGroup = - vendorLicenseManager.createLicenseKeyGroup(licenseKeyGroupEntity); - StringWrapperResponse result = - createdLicenseKeyGroup != null ? new StringWrapperResponse(createdLicenseKeyGroup.getId()) - : null; - return Response.ok(result).build(); - } - - /** - * Update license key group response. - * - * @param request the request - * @param vlmId the vlm id - * @param licenseKeyGroupId the license key group id - * @param user the user - * @return the response - */ - public Response updateLicenseKeyGroup(LicenseKeyGroupRequestDto request, String vlmId, - String versionId, - String licenseKeyGroupId, String user) { - LicenseKeyGroupEntity licenseKeyGroupEntity = - new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity() + /** + * Update license key group response. + * + * @param request the request + * @param vlmId the vlm id + * @param licenseKeyGroupId the license key group id + * @param user the user + * @return the response + */ + public Response updateLicenseKeyGroup(LicenseKeyGroupRequestDto request, String vlmId, String versionId, String licenseKeyGroupId, String user) { + LicenseKeyGroupEntity licenseKeyGroupEntity = new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity() .applyMapping(request, LicenseKeyGroupEntity.class); - licenseKeyGroupEntity.setVendorLicenseModelId(vlmId); - licenseKeyGroupEntity.setVersion(new Version(versionId)); - licenseKeyGroupEntity.setId(licenseKeyGroupId); - - vendorLicenseManager.updateLicenseKeyGroup(licenseKeyGroupEntity); - return Response.ok().build(); - } - - /** - * Gets license key group. - * - * @param vlmId the vlm id - * @param versionId the version - * @param licenseKeyGroupId the license key group id - * @param user the user - * @return the license key group - */ - public Response getLicenseKeyGroup(String vlmId, String versionId, String licenseKeyGroupId, - String user) { - LicenseKeyGroupEntity lkgInput = new LicenseKeyGroupEntity(); - lkgInput.setVendorLicenseModelId(vlmId); - lkgInput.setVersion(new Version(versionId)); - lkgInput.setId(licenseKeyGroupId); - LicenseKeyGroupEntity licenseKeyGroup = vendorLicenseManager.getLicenseKeyGroup(lkgInput); + licenseKeyGroupEntity.setVendorLicenseModelId(vlmId); + licenseKeyGroupEntity.setVersion(new Version(versionId)); + licenseKeyGroupEntity.setId(licenseKeyGroupId); + vendorLicenseManager.updateLicenseKeyGroup(licenseKeyGroupEntity); + return Response.ok().build(); + } - LicenseKeyGroupEntityDto licenseKeyGroupEntityDto = licenseKeyGroup == null ? null : - new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto() - .applyMapping(licenseKeyGroup, LicenseKeyGroupEntityDto.class); - return Response.ok(licenseKeyGroupEntityDto).build(); - } + /** + * Gets license key group. + * + * @param vlmId the vlm id + * @param versionId the version + * @param licenseKeyGroupId the license key group id + * @param user the user + * @return the license key group + */ + public Response getLicenseKeyGroup(String vlmId, String versionId, String licenseKeyGroupId, String user) { + LicenseKeyGroupEntity lkgInput = new LicenseKeyGroupEntity(); + lkgInput.setVendorLicenseModelId(vlmId); + lkgInput.setVersion(new Version(versionId)); + lkgInput.setId(licenseKeyGroupId); + LicenseKeyGroupEntity licenseKeyGroup = vendorLicenseManager.getLicenseKeyGroup(lkgInput); + LicenseKeyGroupEntityDto licenseKeyGroupEntityDto = licenseKeyGroup == null ? null + : new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto().applyMapping(licenseKeyGroup, LicenseKeyGroupEntityDto.class); + return Response.ok(licenseKeyGroupEntityDto).build(); + } - /** - * Delete license key group response. - * - * @param vlmId the vlm id - * @param licenseKeyGroupId the license key group id - * @param user the user - * @return the response - */ - public Response deleteLicenseKeyGroup(String vlmId, String versionId, String licenseKeyGroupId, - String user) { - LicenseKeyGroupEntity lkgInput = new LicenseKeyGroupEntity(); - lkgInput.setVendorLicenseModelId(vlmId); - lkgInput.setVersion(new Version(versionId)); - lkgInput.setId(licenseKeyGroupId); - vendorLicenseManager.deleteLicenseKeyGroup(lkgInput); - return Response.ok().build(); - } + /** + * Delete license key group response. + * + * @param vlmId the vlm id + * @param licenseKeyGroupId the license key group id + * @param user the user + * @return the response + */ + public Response deleteLicenseKeyGroup(String vlmId, String versionId, String licenseKeyGroupId, String user) { + LicenseKeyGroupEntity lkgInput = new LicenseKeyGroupEntity(); + lkgInput.setVendorLicenseModelId(vlmId); + lkgInput.setVersion(new Version(versionId)); + lkgInput.setId(licenseKeyGroupId); + vendorLicenseManager.deleteLicenseKeyGroup(lkgInput); + return Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java index df6363c883..0255b14753 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VendorLicenseModelsImpl.java @@ -13,10 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.openecomp.sdcrests.vendorlicense.rest.services; +import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME; +import static org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelActionRequestDto.VendorLicenseModelAction.Submit; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.function.Predicate; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.core.dao.UniqueValueDaoFactory; import org.openecomp.core.util.UniqueValueUtil; import org.openecomp.sdc.activitylog.ActivityLogManager; @@ -65,17 +77,6 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.function.Predicate; - -import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; -import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.*; -import static org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelActionRequestDto.VendorLicenseModelAction.Submit; - @Named @Service("vendorLicenseModels") @Scope(value = "prototype") @@ -83,75 +84,57 @@ import static org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelActio public class VendorLicenseModelsImpl implements VendorLicenseModels { private static final String SUBMIT_ITEM_ACTION = "Submit_Item"; - private static final String SUBMIT_HEALED_VERSION_ERROR = - "VLM Id %s: Error while submitting version %s created based on Certified version %s for healing purpose."; + private static final String SUBMIT_HEALED_VERSION_ERROR = "VLM Id %s: Error while submitting version %s created based on Certified version %s for healing purpose."; private static final Logger LOGGER = LoggerFactory.getLogger(VendorLicenseModelsImpl.class); private PermissionsManager permissionsManager = PermissionsManagerFactory.getInstance().createInterface(); - private NotificationPropagationManager notifier = - NotificationPropagationManagerFactory.getInstance().createInterface(); - + private NotificationPropagationManager notifier = NotificationPropagationManagerFactory.getInstance().createInterface(); private AsdcItemManager asdcItemManager = AsdcItemManagerFactory.getInstance().createInterface(); private VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface(); private VendorLicenseManager vendorLicenseManager = VendorLicenseManagerFactory.getInstance().createInterface(); private ActivityLogManager activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); - private UniqueValueUtil uniqueValueUtil = - new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface()); + private UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface()); @Override public Response listLicenseModels(String versionStatus, String itemStatus, String user) { Predicate<Item> itemPredicate = createItemPredicate(versionStatus, itemStatus, user); - GenericCollectionWrapper<ItemDto> results = new GenericCollectionWrapper<>(); MapItemToDto mapper = new MapItemToDto(); - asdcItemManager.list(itemPredicate).stream() - .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())) - .forEach(item -> results.add(mapper.applyMapping(item, ItemDto.class))); - + asdcItemManager.list(itemPredicate).stream().sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())) + .forEach(item -> results.add(mapper.applyMapping(item, ItemDto.class))); return Response.ok(results).build(); } @Override public Response createLicenseModel(VendorLicenseModelRequestDto request, String user) { - Item item = new Item(); item.setType(ItemType.vlm.name()); item.setOwner(user); item.setStatus(ItemStatus.ACTIVE); item.setName(request.getVendorName()); item.setDescription(request.getDescription()); - uniqueValueUtil.validateUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME, item.getName()); item = asdcItemManager.create(item); uniqueValueUtil.createUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME, item.getName()); - Version version = versioningManager.create(item.getId(), new Version(), null); - VendorLicenseModelEntity vlm = new MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity() - .applyMapping(request, VendorLicenseModelEntity.class); + .applyMapping(request, VendorLicenseModelEntity.class); vlm.setId(item.getId()); vlm.setVersion(version); - vendorLicenseManager.createVendorLicenseModel(vlm); versioningManager.publish(item.getId(), version, "Initial vlm:" + vlm.getVendorName()); - ItemCreationDto itemCreationDto = new ItemCreationDto(); itemCreationDto.setItemId(item.getId()); itemCreationDto.setVersion(new MapVersionToDto().applyMapping(version, VersionDto.class)); - - activityLogManager - .logActivity(new ActivityLogEntity(vlm.getId(), version, ActivityType.Create, user, true, "", "")); - + activityLogManager.logActivity(new ActivityLogEntity(vlm.getId(), version, ActivityType.Create, user, true, "", "")); return Response.ok(itemCreationDto).build(); } @Override - public Response updateLicenseModel(VendorLicenseModelRequestDto request, String vlmId, String versionId, - String user) { + public Response updateLicenseModel(VendorLicenseModelRequestDto request, String vlmId, String versionId, String user) { VendorLicenseModelEntity vlm = new MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity() - .applyMapping(request, VendorLicenseModelEntity.class); + .applyMapping(request, VendorLicenseModelEntity.class); vlm.setId(vlmId); vlm.setVersion(new Version(versionId)); - vendorLicenseManager.updateVendorLicenseModel(vlm); return Response.ok().build(); } @@ -160,74 +143,56 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels { public Response getLicenseModel(String vlmId, String versionId, String user) { Version version = versioningManager.get(vlmId, new Version(versionId)); VendorLicenseModelEntity vlm = vendorLicenseManager.getVendorLicenseModel(vlmId, version); - try { - HealingManagerFactory.getInstance().createInterface() - .healItemVersion(vlmId, version, ItemType.vlm, false) - .ifPresent(healedVersion -> { - vlm.setVersion(healedVersion); - if (version.getStatus() == VersionStatus.Certified) { - submitHealedVersion(vlmId, healedVersion, versionId, user); - } - }); + HealingManagerFactory.getInstance().createInterface().healItemVersion(vlmId, version, ItemType.vlm, false).ifPresent(healedVersion -> { + vlm.setVersion(healedVersion); + if (version.getStatus() == VersionStatus.Certified) { + submitHealedVersion(vlmId, healedVersion, versionId, user); + } + }); } catch (Exception e) { LOGGER.error(String.format("Error while auto healing VLM with Id %s and version %s", vlmId, versionId), e); } - - VendorLicenseModelEntityDto vlmDto = - new MapVendorLicenseModelEntityToDto().applyMapping(vlm, VendorLicenseModelEntityDto.class); + VendorLicenseModelEntityDto vlmDto = new MapVendorLicenseModelEntityToDto().applyMapping(vlm, VendorLicenseModelEntityDto.class); return Response.ok(vlmDto).build(); } @Override public Response deleteLicenseModel(String vlmId, String user) { Item vlm = asdcItemManager.get(vlmId); - if (!vlm.getType().equals(ItemType.vlm.name())) { - throw new CoreException((new ErrorCode.ErrorCodeBuilder() - .withMessage(String.format("Vlm with id %s does not exist.", vlmId)) - .build())); + throw new CoreException((new ErrorCode.ErrorCodeBuilder().withMessage(String.format("Vlm with id %s does not exist.", vlmId)).build())); } - Integer certifiedVersionsCounter = vlm.getVersionStatusCounters().get(VersionStatus.Certified); if (Objects.isNull(certifiedVersionsCounter) || certifiedVersionsCounter == 0) { asdcItemManager.delete(vlm); permissionsManager.deleteItemPermissions(vlmId); uniqueValueUtil.deleteUniqueValue(VendorLicenseConstants.UniqueValues.VENDOR_NAME, vlm.getName()); notifyUsers(vlmId, vlm.getName(), null, null, user, NotificationEventTypes.DELETE); - return Response.ok().build(); } else { - return Response.status(Response.Status.FORBIDDEN) - .entity(new Exception(Messages.DELETE_VLM_ERROR.getErrorMessage())).build(); + return Response.status(Response.Status.FORBIDDEN).entity(new Exception(Messages.DELETE_VLM_ERROR.getErrorMessage())).build(); } } @Override - public Response actOnLicenseModel(VendorLicenseModelActionRequestDto request, String vlmId, String versionId, - String user) { + public Response actOnLicenseModel(VendorLicenseModelActionRequestDto request, String vlmId, String versionId, String user) { Version version = new Version(versionId); - if (request.getAction() == Submit) { if (!permissionsManager.isAllowed(vlmId, user, SUBMIT_ITEM_ACTION)) { - return Response.status(Response.Status.FORBIDDEN) - .entity(new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build(); + return Response.status(Response.Status.FORBIDDEN).entity(new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build(); } String message = request.getSubmitRequest() == null ? "Submit" : request.getSubmitRequest().getMessage(); submit(vlmId, version, message, user); - notifyUsers(vlmId, null, version, message, user, NotificationEventTypes.SUBMIT); - } return Response.ok().build(); } private void submit(String vlmId, Version version, String message, String user) { - vendorLicenseManager.validate(vlmId, version); versioningManager.submit(vlmId, version, message); - activityLogManager - .logActivity(new ActivityLogEntity(vlmId, version, ActivityType.Submit, user, true, "", message)); + activityLogManager.logActivity(new ActivityLogEntity(vlmId, version, ActivityType.Submit, user, true, "", message)); } private void submitHealedVersion(String vlmId, Version healedVersion, String baseVersionId, String user) { @@ -238,21 +203,16 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels { } } - private void notifyUsers(String itemId, String itemName, Version version, String message, String userName, - NotificationEventTypes eventType) { + private void notifyUsers(String itemId, String itemName, Version version, String message, String userName, NotificationEventTypes eventType) { Map<String, Object> eventProperties = new HashMap<>(); eventProperties.put(ITEM_NAME, itemName == null ? asdcItemManager.get(itemId).getName() : itemName); eventProperties.put(ITEM_ID, itemId); - if (version != null) { - eventProperties.put(VERSION_NAME, - version.getName() == null ? versioningManager.get(itemId, version).getName() : version.getName()); + eventProperties.put(VERSION_NAME, version.getName() == null ? versioningManager.get(itemId, version).getName() : version.getName()); eventProperties.put(VERSION_ID, version.getId()); } - eventProperties.put(SUBMIT_DESCRIPTION, message); eventProperties.put(PERMISSION_USER, userName); - Event syncEvent = new SyncEvent(eventType.getEventName(), itemId, eventProperties, itemId); try { notifier.notifySubscribers(syncEvent, userName); @@ -261,6 +221,27 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels { } } + private boolean userHasPermission(String itemId, String userId) { + return permissionsManager.getUserItemPermission(itemId, userId) + .map(permission -> permission.matches(PermissionTypes.Contributor.name() + "|" + PermissionTypes.Owner.name())).orElse(false); + } + + private Predicate<Item> createItemPredicate(String versionStatus, String itemStatus, String user) { + Predicate<Item> itemPredicate = item -> ItemType.vlm.name().equals(item.getType()); + if (ItemStatus.ARCHIVED.name().equals(itemStatus)) { + itemPredicate = itemPredicate.and(item -> ItemStatus.ARCHIVED.equals(item.getStatus())); + } else { + itemPredicate = itemPredicate.and(item -> ItemStatus.ACTIVE.equals(item.getStatus())); + if (VersionStatus.Certified.name().equals(versionStatus)) { + itemPredicate = itemPredicate.and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Certified)); + } else if (VersionStatus.Draft.name().equals(versionStatus)) { + itemPredicate = itemPredicate + .and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Draft) && userHasPermission(item.getId(), user)); + } + } + return itemPredicate; + } + private class SyncEvent implements Event { private String eventType; @@ -295,33 +276,4 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels { return entityId; } } - - private boolean userHasPermission(String itemId, String userId) { - return permissionsManager.getUserItemPermission(itemId, userId) - .map(permission -> permission - .matches(PermissionTypes.Contributor.name() + "|" + PermissionTypes.Owner.name())) - .orElse(false); - } - - private Predicate<Item> createItemPredicate(String versionStatus, String itemStatus, String user) { - Predicate<Item> itemPredicate = item -> ItemType.vlm.name().equals(item.getType()); - - if (ItemStatus.ARCHIVED.name().equals(itemStatus)) { - itemPredicate = itemPredicate.and(item -> ItemStatus.ARCHIVED.equals(item.getStatus())); - } else { - itemPredicate = itemPredicate.and(item -> ItemStatus.ACTIVE.equals(item.getStatus())); - - if (VersionStatus.Certified.name().equals(versionStatus)) { - itemPredicate = - itemPredicate.and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Certified)); - - } else if (VersionStatus.Draft.name().equals(versionStatus)) { - itemPredicate = itemPredicate - .and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Draft) - && userHasPermission(item.getId(), user)); - } - } - return itemPredicate; - } - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VlmUniqueTypeProvider.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VlmUniqueTypeProvider.java index 5beeec242f..91e1ac5593 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VlmUniqueTypeProvider.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/src/main/java/org/openecomp/sdcrests/vendorlicense/rest/services/VlmUniqueTypeProvider.java @@ -15,20 +15,18 @@ */ package org.openecomp.sdcrests.vendorlicense.rest.services; -import org.openecomp.sdcrests.uniquevalue.types.UniqueTypesProvider; +import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.UniqueValues.VENDOR_NAME; import java.util.Collections; import java.util.Map; - -import static org.openecomp.sdc.vendorlicense.VendorLicenseConstants.UniqueValues.VENDOR_NAME; +import org.openecomp.sdcrests.uniquevalue.types.UniqueTypesProvider; public class VlmUniqueTypeProvider implements UniqueTypesProvider { - private static final Map<String, String> uniqueTypes = - Collections.singletonMap("VlmName", VENDOR_NAME); + private static final Map<String, String> uniqueTypes = Collections.singletonMap("VlmName", VENDOR_NAME); - @Override - public Map<String, String> listUniqueTypes() { - return uniqueTypes; - } + @Override + public Map<String, String> listUniqueTypes() { + return uniqueTypes; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/ChoiceOrOtherDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/ChoiceOrOtherDto.java index ba8f57f79f..fc3a41903b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/ChoiceOrOtherDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/ChoiceOrOtherDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,59 +17,53 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; +import javax.validation.constraints.NotNull; import org.hibernate.validator.group.GroupSequenceProvider; import org.openecomp.sdcrests.vendorlicense.types.validation.ChoiceOrOtherSequenceProvider; import org.openecomp.sdcrests.vendorlicense.types.validation.OtherChoiceValidation; -import javax.validation.constraints.NotNull; - @GroupSequenceProvider(value = ChoiceOrOtherSequenceProvider.class) public class ChoiceOrOtherDto<E extends Enum<E>> { - @NotNull - private E choice; - @NotNull(message = "may not be null when choice is set to 'Other'.", - groups = OtherChoiceValidation.class) - private String other; - - public E getChoice() { - return choice; - } - - public void setChoice(E choice) { - this.choice = choice; - } - public String getOther() { - return other; - } + @NotNull + private E choice; + @NotNull(message = "may not be null when choice is set to 'Other'.", groups = OtherChoiceValidation.class) + private String other; - public void setOther(String other) { - this.other = other; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; + public E getChoice() { + return choice; } - if (obj == null || getClass() != obj.getClass()) { - return false; + + public void setChoice(E choice) { + this.choice = choice; } - ChoiceOrOtherDto<?> that = (ChoiceOrOtherDto<?>) obj; + public String getOther() { + return other; + } - return choice != null ? choice.equals(that.choice) - : that.choice == null && (other != null ? other.equals(that.other) : that.other == null); + public void setOther(String other) { + this.other = other; + } - } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + ChoiceOrOtherDto<?> that = (ChoiceOrOtherDto<?>) obj; + return choice != null ? choice.equals(that.choice) : that.choice == null && (other != null ? other.equals(that.other) : that.other == null); + } - @Override - public int hashCode() { - int result = choice != null ? choice.hashCode() : 0; - result = 31 * result + (other != null ? other.hashCode() : 0); - return result; - } + @Override + public int hashCode() { + int result = choice != null ? choice.hashCode() : 0; + result = 31 * result + (other != null ? other.hashCode() : 0); + return result; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolEntityDto.java index 88d08d6aa1..835d6fcbfe 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolEntityDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,41 +17,39 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; - import io.swagger.v3.oas.annotations.media.Schema; - import java.util.Set; @Schema(description = "EntitlementPoolEntity") public class EntitlementPoolEntityDto extends EntitlementPoolRequestDto { - private String id; - private Set<String> referencingFeatureGroups; - private String versionUUID; - public String getId() { - return id; - } + private String id; + private Set<String> referencingFeatureGroups; + private String versionUUID; + + public String getId() { + return id; + } - public void setId(String id) { - this.id = id; - } + public void setId(String id) { + this.id = id; + } - public Set<String> getReferencingFeatureGroups() { - return referencingFeatureGroups; - } + public Set<String> getReferencingFeatureGroups() { + return referencingFeatureGroups; + } - public void setReferencingFeatureGroups(Set<String> referencingFeatureGroups) { - this.referencingFeatureGroups = referencingFeatureGroups; - } + public void setReferencingFeatureGroups(Set<String> referencingFeatureGroups) { + this.referencingFeatureGroups = referencingFeatureGroups; + } - public String getversionUUID() { - return versionUUID; - } + public String getversionUUID() { + return versionUUID; + } - public void setVersionUUID(String versionUUID) { - this.versionUUID = versionUUID; - } + public void setVersionUUID(String versionUUID) { + this.versionUUID = versionUUID; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java index 642156fa30..35e6f31e28 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/EntitlementPoolRequestDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,17 +17,14 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; - import io.swagger.v3.oas.annotations.media.Schema; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import org.hibernate.validator.constraints.NotBlank; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolType; import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope; import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit; - import javax.validation.Valid; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; @@ -36,109 +33,102 @@ import javax.validation.constraints.Size; @JsonIgnoreProperties({"time", "aggregationFunction", "entitlementMetric"}) public class EntitlementPoolRequestDto { - @NotNull - @Size(max = 120) - private String name; - - @NotBlank(message = "is mandatory and should not be empty") - @Size(max = 100) - private String manufacturerReferenceNumber; - - @Size(max = 1000) - private String description; - - @NotNull - private EntitlementPoolType type; - - private Integer thresholdValue; - - private ThresholdUnit thresholdUnits; - @Size(max = 120) - private String increments; - - @Valid - private MultiChoiceOrOtherDto<OperationalScope> operationalScope; - - private String startDate; - private String expiryDate; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getManufacturerReferenceNumber() { - return manufacturerReferenceNumber; - } - - public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) { - this.manufacturerReferenceNumber = manufacturerReferenceNumber; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public EntitlementPoolType getType() { - return type; - } - - public void setType(EntitlementPoolType type) { - this.type = type; - } - - public Integer getThresholdValue() { - return thresholdValue; - } - - public void setThresholdValue(Integer thresholdValue) { - this.thresholdValue = thresholdValue; - } - - public ThresholdUnit getThresholdUnits() { - return thresholdUnits; - } - - public void setThresholdUnits(ThresholdUnit thresholdUnits) { - this.thresholdUnits = thresholdUnits; - } - - public String getIncrements() { - return increments; - } - - public void setIncrements(String increments) { - this.increments = increments; - } - - public MultiChoiceOrOtherDto<OperationalScope> getOperationalScope() { - return operationalScope; - } - - public void setOperationalScope(MultiChoiceOrOtherDto<OperationalScope> operationalScope) { - this.operationalScope = operationalScope; - } - - public String getStartDate() { - return startDate; - } - - public void setStartDate(String startDate) { - this.startDate = startDate; - } - - public String getExpiryDate() { - return expiryDate; - } - - public void setExpiryDate(String expiryDate) { - this.expiryDate = expiryDate; - } + @NotNull + @Size(max = 120) + private String name; + @NotBlank(message = "is mandatory and should not be empty") + @Size(max = 100) + private String manufacturerReferenceNumber; + @Size(max = 1000) + private String description; + @NotNull + private EntitlementPoolType type; + private Integer thresholdValue; + private ThresholdUnit thresholdUnits; + @Size(max = 120) + private String increments; + @Valid + private MultiChoiceOrOtherDto<OperationalScope> operationalScope; + private String startDate; + private String expiryDate; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getManufacturerReferenceNumber() { + return manufacturerReferenceNumber; + } + + public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) { + this.manufacturerReferenceNumber = manufacturerReferenceNumber; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public EntitlementPoolType getType() { + return type; + } + + public void setType(EntitlementPoolType type) { + this.type = type; + } + + public Integer getThresholdValue() { + return thresholdValue; + } + + public void setThresholdValue(Integer thresholdValue) { + this.thresholdValue = thresholdValue; + } + + public ThresholdUnit getThresholdUnits() { + return thresholdUnits; + } + + public void setThresholdUnits(ThresholdUnit thresholdUnits) { + this.thresholdUnits = thresholdUnits; + } + + public String getIncrements() { + return increments; + } + + public void setIncrements(String increments) { + this.increments = increments; + } + + public MultiChoiceOrOtherDto<OperationalScope> getOperationalScope() { + return operationalScope; + } + + public void setOperationalScope(MultiChoiceOrOtherDto<OperationalScope> operationalScope) { + this.operationalScope = operationalScope; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getExpiryDate() { + return expiryDate; + } + + public void setExpiryDate(String expiryDate) { + this.expiryDate = expiryDate; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java index 919fdb21c2..03bf2de328 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupDescriptorDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,45 +17,42 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; - import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; public class FeatureGroupDescriptorDto { - @NotNull - @Size(max = 120) - private String name; - - @Size(max = 1000) - private String description; - @NotNull - private String partNumber; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getPartNumber() { - return partNumber; - } - - public void setPartNumber(String partNumber) { - this.partNumber = partNumber; - } + @NotNull + @Size(max = 120) + private String name; + @Size(max = 1000) + private String description; + @NotNull + private String partNumber; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getPartNumber() { + return partNumber; + } + + public void setPartNumber(String partNumber) { + this.partNumber = partNumber; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupEntityDto.java index eac6ed38fe..679dfbbeca 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupEntityDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,52 +17,50 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; - import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.constraints.Size; import java.util.Set; +import javax.validation.constraints.Size; @Schema(description = "FeatureGroupEntity") public class FeatureGroupEntityDto extends FeatureGroupDescriptorDto { - private String id; - private Set<String> licenseKeyGroupsIds; - @Size(min = 1) - private Set<String> entitlementPoolsIds; - private Set<String> referencingLicenseAgreements; - public String getId() { - return id; - } + private String id; + private Set<String> licenseKeyGroupsIds; + @Size(min = 1) + private Set<String> entitlementPoolsIds; + private Set<String> referencingLicenseAgreements; + + public String getId() { + return id; + } - public void setId(String id) { - this.id = id; - } + public void setId(String id) { + this.id = id; + } - public Set<String> getLicenseKeyGroupsIds() { - return licenseKeyGroupsIds; - } + public Set<String> getLicenseKeyGroupsIds() { + return licenseKeyGroupsIds; + } - public void setLicenseKeyGroupsIds(Set<String> licenseKeyGroupsIds) { - this.licenseKeyGroupsIds = licenseKeyGroupsIds; - } + public void setLicenseKeyGroupsIds(Set<String> licenseKeyGroupsIds) { + this.licenseKeyGroupsIds = licenseKeyGroupsIds; + } - public Set<String> getEntitlementPoolsIds() { - return entitlementPoolsIds; - } + public Set<String> getEntitlementPoolsIds() { + return entitlementPoolsIds; + } - public void setEntitlementPoolsIds(Set<String> entitlementPoolsIds) { - this.entitlementPoolsIds = entitlementPoolsIds; - } + public void setEntitlementPoolsIds(Set<String> entitlementPoolsIds) { + this.entitlementPoolsIds = entitlementPoolsIds; + } - public Set<String> getReferencingLicenseAgreements() { - return referencingLicenseAgreements; - } + public Set<String> getReferencingLicenseAgreements() { + return referencingLicenseAgreements; + } - public void setReferencingLicenseAgreements(Set<String> referencingLicenseAgreements) { - this.referencingLicenseAgreements = referencingLicenseAgreements; - } + public void setReferencingLicenseAgreements(Set<String> referencingLicenseAgreements) { + this.referencingLicenseAgreements = referencingLicenseAgreements; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupModelDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupModelDto.java index 44404c3b1f..485e362288 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupModelDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupModelDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,52 +17,49 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; - - import io.swagger.v3.oas.annotations.media.Schema; - import java.util.Collection; import java.util.Set; @Schema(description = "FeatureGroupModel") public class FeatureGroupModelDto extends FeatureGroupDescriptorDto { - private String id; - private Set<String> referencingLicenseAgreements; - private Collection<LicenseKeyGroupEntityDto> licenseKeyGroups; - private Collection<EntitlementPoolEntityDto> entitlementPools; - public String getId() { - return id; - } + private String id; + private Set<String> referencingLicenseAgreements; + private Collection<LicenseKeyGroupEntityDto> licenseKeyGroups; + private Collection<EntitlementPoolEntityDto> entitlementPools; + + public String getId() { + return id; + } - public void setId(String id) { - this.id = id; - } + public void setId(String id) { + this.id = id; + } - public Set<String> getReferencingLicenseAgreements() { - return referencingLicenseAgreements; - } + public Set<String> getReferencingLicenseAgreements() { + return referencingLicenseAgreements; + } - public void setReferencingLicenseAgreements(Set<String> referencingLicenseAgreements) { - this.referencingLicenseAgreements = referencingLicenseAgreements; - } + public void setReferencingLicenseAgreements(Set<String> referencingLicenseAgreements) { + this.referencingLicenseAgreements = referencingLicenseAgreements; + } - public Collection<LicenseKeyGroupEntityDto> getLicenseKeyGroups() { - return licenseKeyGroups; - } + public Collection<LicenseKeyGroupEntityDto> getLicenseKeyGroups() { + return licenseKeyGroups; + } - public void setLicenseKeyGroups(Collection<LicenseKeyGroupEntityDto> licenseKeyGroups) { - this.licenseKeyGroups = licenseKeyGroups; - } + public void setLicenseKeyGroups(Collection<LicenseKeyGroupEntityDto> licenseKeyGroups) { + this.licenseKeyGroups = licenseKeyGroups; + } - public Collection<EntitlementPoolEntityDto> getEntitlementPools() { - return entitlementPools; - } + public Collection<EntitlementPoolEntityDto> getEntitlementPools() { + return entitlementPools; + } - public void setEntitlementPools(Collection<EntitlementPoolEntityDto> entitlementPools) { - this.entitlementPools = entitlementPools; - } + public void setEntitlementPools(Collection<EntitlementPoolEntityDto> entitlementPools) { + this.entitlementPools = entitlementPools; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupRequestDto.java index 3aefaa1d45..27fb954957 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupRequestDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,33 +17,30 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; - import io.swagger.v3.oas.annotations.media.Schema; - import java.util.Set; @Schema(description = "FeatureGroupRequest") public class FeatureGroupRequestDto extends FeatureGroupDescriptorDto { - private Set<String> addedLicenseKeyGroupsIds; - private Set<String> addedEntitlementPoolsIds; + private Set<String> addedLicenseKeyGroupsIds; + private Set<String> addedEntitlementPoolsIds; - public Set<String> getAddedLicenseKeyGroupsIds() { - return addedLicenseKeyGroupsIds; - } + public Set<String> getAddedLicenseKeyGroupsIds() { + return addedLicenseKeyGroupsIds; + } - public void setAddedLicenseKeyGroupsIds(Set<String> addedLicenseKeyGroupsIds) { - this.addedLicenseKeyGroupsIds = addedLicenseKeyGroupsIds; - } + public void setAddedLicenseKeyGroupsIds(Set<String> addedLicenseKeyGroupsIds) { + this.addedLicenseKeyGroupsIds = addedLicenseKeyGroupsIds; + } - public Set<String> getAddedEntitlementPoolsIds() { - return addedEntitlementPoolsIds; - } + public Set<String> getAddedEntitlementPoolsIds() { + return addedEntitlementPoolsIds; + } - public void setAddedEntitlementPoolsIds(Set<String> addedEntitlementPoolsIds) { - this.addedEntitlementPoolsIds = addedEntitlementPoolsIds; - } + public void setAddedEntitlementPoolsIds(Set<String> addedEntitlementPoolsIds) { + this.addedEntitlementPoolsIds = addedEntitlementPoolsIds; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupUpdateRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupUpdateRequestDto.java index 9e3fab59ee..016735fced 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupUpdateRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/FeatureGroupUpdateRequestDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,33 +17,30 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; - import io.swagger.v3.oas.annotations.media.Schema; - import java.util.Set; @Schema(description = "FeatureGroupUpdateRequest") public class FeatureGroupUpdateRequestDto extends FeatureGroupRequestDto { - private Set<String> removedLicenseKeyGroupsIds; - private Set<String> removedEntitlementPoolsIds; + private Set<String> removedLicenseKeyGroupsIds; + private Set<String> removedEntitlementPoolsIds; - public Set<String> getRemovedLicenseKeyGroupsIds() { - return removedLicenseKeyGroupsIds; - } + public Set<String> getRemovedLicenseKeyGroupsIds() { + return removedLicenseKeyGroupsIds; + } - public void setRemovedLicenseKeyGroupsIds(Set<String> removedLicenseKeyGroupsIds) { - this.removedLicenseKeyGroupsIds = removedLicenseKeyGroupsIds; - } + public void setRemovedLicenseKeyGroupsIds(Set<String> removedLicenseKeyGroupsIds) { + this.removedLicenseKeyGroupsIds = removedLicenseKeyGroupsIds; + } - public Set<String> getRemovedEntitlementPoolsIds() { - return removedEntitlementPoolsIds; - } + public Set<String> getRemovedEntitlementPoolsIds() { + return removedEntitlementPoolsIds; + } - public void setRemovedEntitlementPoolsIds(Set<String> removedEntitlementPoolsIds) { - this.removedEntitlementPoolsIds = removedEntitlementPoolsIds; - } + public void setRemovedEntitlementPoolsIds(Set<String> removedEntitlementPoolsIds) { + this.removedEntitlementPoolsIds = removedEntitlementPoolsIds; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementDescriptorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementDescriptorDto.java index 4239488124..cd72d151dc 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementDescriptorDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementDescriptorDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,58 +17,55 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; -import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm; - import javax.validation.Valid; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseTerm; public class LicenseAgreementDescriptorDto { - @NotNull - @Size(max = 120) - private String name; - - @Size(max = 1000) - private String description; - @NotNull - @Valid - private ChoiceOrOtherDto<LicenseTerm> licenseTerm; - @Size(max = 1000) - private String requirementsAndConstrains; + @NotNull + @Size(max = 120) + private String name; + @Size(max = 1000) + private String description; + @NotNull + @Valid + private ChoiceOrOtherDto<LicenseTerm> licenseTerm; + @Size(max = 1000) + private String requirementsAndConstrains; - public String getName() { - return name; - } + public String getName() { + return name; + } - public void setName(String name) { - this.name = name; - } + public void setName(String name) { + this.name = name; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public ChoiceOrOtherDto<LicenseTerm> getLicenseTerm() { - return licenseTerm; - } + public ChoiceOrOtherDto<LicenseTerm> getLicenseTerm() { + return licenseTerm; + } - public void setLicenseTerm(ChoiceOrOtherDto<LicenseTerm> licenseTerm) { - this.licenseTerm = licenseTerm; - } + public void setLicenseTerm(ChoiceOrOtherDto<LicenseTerm> licenseTerm) { + this.licenseTerm = licenseTerm; + } - public String getRequirementsAndConstrains() { - return requirementsAndConstrains; - } + public String getRequirementsAndConstrains() { + return requirementsAndConstrains; + } - public void setRequirementsAndConstrains(String requirementsAndConstrains) { - this.requirementsAndConstrains = requirementsAndConstrains; - } + public void setRequirementsAndConstrains(String requirementsAndConstrains) { + this.requirementsAndConstrains = requirementsAndConstrains; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementEntityDto.java index e3b6207eaa..423edcfe59 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementEntityDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,35 +17,32 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; - - import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.constraints.Size; import java.util.Set; +import javax.validation.constraints.Size; @Schema(description = "LicenseAgreementEntity") public class LicenseAgreementEntityDto extends LicenseAgreementDescriptorDto { - private String id; - @Size(min = 1) - private Set<String> featureGroupsIds; - public String getId() { - return id; - } + private String id; + @Size(min = 1) + private Set<String> featureGroupsIds; + + public String getId() { + return id; + } - public void setId(String id) { - this.id = id; - } + public void setId(String id) { + this.id = id; + } - public Set<String> getFeatureGroupsIds() { - return featureGroupsIds; - } + public Set<String> getFeatureGroupsIds() { + return featureGroupsIds; + } - public void setFeatureGroupsIds(Set<String> featureGroupsIds) { - this.featureGroupsIds = featureGroupsIds; - } + public void setFeatureGroupsIds(Set<String> featureGroupsIds) { + this.featureGroupsIds = featureGroupsIds; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementModelDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementModelDto.java index 3c97756c3c..8365476e8d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementModelDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementModelDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,33 +17,30 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; - - import io.swagger.v3.oas.annotations.media.Schema; - import java.util.Set; @Schema(description = "LicenseAgreementModel") public class LicenseAgreementModelDto extends LicenseAgreementDescriptorDto { - private String id; - private Set<FeatureGroupEntityDto> featureGroups; - public String getId() { - return id; - } + private String id; + private Set<FeatureGroupEntityDto> featureGroups; + + public String getId() { + return id; + } - public void setId(String id) { - this.id = id; - } + public void setId(String id) { + this.id = id; + } - public Set<FeatureGroupEntityDto> getFeatureGroups() { - return featureGroups; - } + public Set<FeatureGroupEntityDto> getFeatureGroups() { + return featureGroups; + } - public void setFeatureGroups(Set<FeatureGroupEntityDto> featureGroups) { - this.featureGroups = featureGroups; - } + public void setFeatureGroups(Set<FeatureGroupEntityDto> featureGroups) { + this.featureGroups = featureGroups; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementRequestDto.java index 358dcef8e2..ee90e989e2 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementRequestDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,24 +17,21 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; - import io.swagger.v3.oas.annotations.media.Schema; - import java.util.Set; @Schema(description = "LicenseAgreementRequest") public class LicenseAgreementRequestDto extends LicenseAgreementDescriptorDto { - private Set<String> addedFeatureGroupsIds; + private Set<String> addedFeatureGroupsIds; - public Set<String> getAddedFeatureGroupsIds() { - return addedFeatureGroupsIds; - } + public Set<String> getAddedFeatureGroupsIds() { + return addedFeatureGroupsIds; + } - public void setAddedFeatureGroupsIds(Set<String> addedFeatureGroupsIds) { - this.addedFeatureGroupsIds = addedFeatureGroupsIds; - } + public void setAddedFeatureGroupsIds(Set<String> addedFeatureGroupsIds) { + this.addedFeatureGroupsIds = addedFeatureGroupsIds; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementUpdateRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementUpdateRequestDto.java index 6baba8acb3..3fbba212dd 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementUpdateRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseAgreementUpdateRequestDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,23 +17,21 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; - import io.swagger.v3.oas.annotations.media.Schema; - import java.util.Set; @Schema(description = "LicenseAgreementUpdateRequest") public class LicenseAgreementUpdateRequestDto extends LicenseAgreementRequestDto { - private Set<String> removedFeatureGroupsIds; - public Set<String> getRemovedFeatureGroupsIds() { - return removedFeatureGroupsIds; - } + private Set<String> removedFeatureGroupsIds; + + public Set<String> getRemovedFeatureGroupsIds() { + return removedFeatureGroupsIds; + } - public void setRemovedFeatureGroupsIds(Set<String> removedFeatureGroupsIds) { - this.removedFeatureGroupsIds = removedFeatureGroupsIds; - } + public void setRemovedFeatureGroupsIds(Set<String> removedFeatureGroupsIds) { + this.removedFeatureGroupsIds = removedFeatureGroupsIds; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupEntityDto.java index 6186398d29..6ee80bd801 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupEntityDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,38 +17,37 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; - import java.util.Set; public class LicenseKeyGroupEntityDto extends LicenseKeyGroupRequestDto { - private String id; - private Set<String> referencingFeatureGroups; - private String versionUUID; - public String getId() { - return id; - } + private String id; + private Set<String> referencingFeatureGroups; + private String versionUUID; + + public String getId() { + return id; + } - public void setId(String id) { - this.id = id; - } + public void setId(String id) { + this.id = id; + } - public Set<String> getReferencingFeatureGroups() { - return referencingFeatureGroups; - } + public Set<String> getReferencingFeatureGroups() { + return referencingFeatureGroups; + } - public void setReferencingFeatureGroups(Set<String> referencingFeatureGroups) { - this.referencingFeatureGroups = referencingFeatureGroups; - } + public void setReferencingFeatureGroups(Set<String> referencingFeatureGroups) { + this.referencingFeatureGroups = referencingFeatureGroups; + } - public String getVersionUUID() { - return versionUUID; - } + public String getVersionUUID() { + return versionUUID; + } - public void setVersionUUID(String versionUUID) { - this.versionUUID = versionUUID; - } + public void setVersionUUID(String versionUUID) { + this.versionUUID = versionUUID; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupRequestDto.java index c1e2ef05bf..2eabb0aa4a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LicenseKeyGroupRequestDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,121 +17,112 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; -import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyType; -import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope; -import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit; - import javax.validation.Valid; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; +import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyType; +import org.openecomp.sdc.vendorlicense.dao.types.OperationalScope; +import org.openecomp.sdc.vendorlicense.dao.types.ThresholdUnit; public class LicenseKeyGroupRequestDto { - @NotNull - @Size(max = 120) - private String name; - - @Size(max = 100) - private String manufacturerReferenceNumber; - - @Size(max = 1000) - private String description; - - @NotNull - private LicenseKeyType type; - - @Valid - private MultiChoiceOrOtherDto<OperationalScope> operationalScope; - - private String startDate; - private String expiryDate; - - private Integer thresholdValue; - - private ThresholdUnit thresholdUnits; - - @Size(max = 120) - private String increments; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getManufacturerReferenceNumber() { - return manufacturerReferenceNumber; - } - - public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) { - this.manufacturerReferenceNumber = manufacturerReferenceNumber; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public LicenseKeyType getType() { - return type; - } - - public void setType(LicenseKeyType type) { - this.type = type; - } - - public MultiChoiceOrOtherDto<OperationalScope> getOperationalScope() { - return operationalScope; - } - - public void setOperationalScope(MultiChoiceOrOtherDto<OperationalScope> operationalScope) { - this.operationalScope = operationalScope; - } - - public String getStartDate() { - return startDate; - } - - public void setStartDate(String startDate) { - this.startDate = startDate; - } - - public String getExpiryDate() { - return expiryDate; - } - - public void setExpiryDate(String expiryDate) { - this.expiryDate = expiryDate; - } - - public Integer getThresholdValue() { - return thresholdValue; - } - - public void setThresholdValue(Integer thresholdValue) { - this.thresholdValue = thresholdValue; - } - - public ThresholdUnit getThresholdUnits() { - return thresholdUnits; - } - - public void setThresholdUnits(ThresholdUnit thresholdUnits) { - this.thresholdUnits = thresholdUnits; - } - - public String getIncrements() { - return increments; - } - public void setIncrements(String increments) { - this.increments = increments; - } + @NotNull + @Size(max = 120) + private String name; + @Size(max = 100) + private String manufacturerReferenceNumber; + @Size(max = 1000) + private String description; + @NotNull + private LicenseKeyType type; + @Valid + private MultiChoiceOrOtherDto<OperationalScope> operationalScope; + private String startDate; + private String expiryDate; + private Integer thresholdValue; + private ThresholdUnit thresholdUnits; + @Size(max = 120) + private String increments; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getManufacturerReferenceNumber() { + return manufacturerReferenceNumber; + } + + public void setManufacturerReferenceNumber(String manufacturerReferenceNumber) { + this.manufacturerReferenceNumber = manufacturerReferenceNumber; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public LicenseKeyType getType() { + return type; + } + + public void setType(LicenseKeyType type) { + this.type = type; + } + + public MultiChoiceOrOtherDto<OperationalScope> getOperationalScope() { + return operationalScope; + } + + public void setOperationalScope(MultiChoiceOrOtherDto<OperationalScope> operationalScope) { + this.operationalScope = operationalScope; + } + + public String getStartDate() { + return startDate; + } + + public void setStartDate(String startDate) { + this.startDate = startDate; + } + + public String getExpiryDate() { + return expiryDate; + } + + public void setExpiryDate(String expiryDate) { + this.expiryDate = expiryDate; + } + + public Integer getThresholdValue() { + return thresholdValue; + } + + public void setThresholdValue(Integer thresholdValue) { + this.thresholdValue = thresholdValue; + } + + public ThresholdUnit getThresholdUnits() { + return thresholdUnits; + } + + public void setThresholdUnits(ThresholdUnit thresholdUnits) { + this.thresholdUnits = thresholdUnits; + } + + public String getIncrements() { + return increments; + } + + public void setIncrements(String increments) { + this.increments = increments; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitEntityDto.java index e3e3584b34..a22bb0a64d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitEntityDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,90 +17,89 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; public class LimitEntityDto { - private String id; - private String name; - private String type; - private String description; - private String metric; - private String value; - private String unit; - private String aggregationFunction; - private String time; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getMetric() { - return metric; - } - - public void setMetric(String metric) { - this.metric = metric; - } - - public String getUnit() { - return unit; - } - - public void setUnit(String unit) { - this.unit = unit; - } - - public String getAggregationFunction() { - return aggregationFunction; - } - - public void setAggregationFunction(String aggregationFunction) { - this.aggregationFunction = aggregationFunction; - } - - public String getTime() { - return time; - } - - public void setTime(String time) { - this.time = time; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } + private String id; + private String name; + private String type; + private String description; + private String metric; + private String value; + private String unit; + private String aggregationFunction; + private String time; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getMetric() { + return metric; + } + + public void setMetric(String metric) { + this.metric = metric; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public String getAggregationFunction() { + return aggregationFunction; + } + + public void setAggregationFunction(String aggregationFunction) { + this.aggregationFunction = aggregationFunction; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitRequestDto.java index 116be31a40..fff840c402 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/LimitRequestDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,95 +17,91 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; import io.swagger.v3.oas.annotations.media.Schema; -import org.hibernate.validator.constraints.NotBlank; - import javax.validation.constraints.Size; +import org.hibernate.validator.constraints.NotBlank; @Schema(description = "LimitRequest") public class LimitRequestDto { - @NotBlank(message = "is mandatory and should not be empty") - @Size(max = 120, message = "length should not exceed 120 characters.") - private String name; - @NotBlank(message = "is mandatory and should not be empty") - private String type; - @Size(max = 1000, message = "length should not exceed 1000 characters.") - private String description; - @NotBlank(message = "is mandatory and should not be empty") - private String metric; - @NotBlank(message = "is mandatory and should not be empty") - private String value; - private String unit; - private String aggregationFunction; - private String time; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getMetric() { - return metric; - } - - public void setMetric(String metric) { - this.metric = metric; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getAggregationFunction() { - return aggregationFunction; - } - - public void setAggregationFunction( - String aggregationFunction) { - this.aggregationFunction = aggregationFunction; - } - - public String getTime() { - return time; - } - - public void setTime(String time) { - this.time = time; - } - - public String getUnit() { - return unit; - } - - public void setUnit(String unit) { - this.unit = unit; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - + @NotBlank(message = "is mandatory and should not be empty") + @Size(max = 120, message = "length should not exceed 120 characters.") + private String name; + @NotBlank(message = "is mandatory and should not be empty") + private String type; + @Size(max = 1000, message = "length should not exceed 1000 characters.") + private String description; + @NotBlank(message = "is mandatory and should not be empty") + private String metric; + @NotBlank(message = "is mandatory and should not be empty") + private String value; + private String unit; + private String aggregationFunction; + private String time; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getMetric() { + return metric; + } + + public void setMetric(String metric) { + this.metric = metric; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getAggregationFunction() { + return aggregationFunction; + } + + public void setAggregationFunction(String aggregationFunction) { + this.aggregationFunction = aggregationFunction; + } + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/MultiChoiceOrOtherDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/MultiChoiceOrOtherDto.java index 1dc8ff2bdd..7a3266da96 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/MultiChoiceOrOtherDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/MultiChoiceOrOtherDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,62 +17,57 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; +import java.util.Set; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; import org.hibernate.validator.group.GroupSequenceProvider; import org.openecomp.sdcrests.vendorlicense.types.validation.MultiChoiceOrOtherSequenceProvider; import org.openecomp.sdcrests.vendorlicense.types.validation.OtherChoiceValidation; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; -import java.util.Set; - @GroupSequenceProvider(value = MultiChoiceOrOtherSequenceProvider.class) public class MultiChoiceOrOtherDto<E extends Enum<E>> { - @NotNull - @Size(min = 1, message = "must contain at least 1 choice.") - private Set<E> choices; - @NotNull(message = "may not be null when choices is set to 'Other'.", - groups = OtherChoiceValidation.class) - private String other; - public Set<E> getChoices() { - return choices; - } + @NotNull + @Size(min = 1, message = "must contain at least 1 choice.") + private Set<E> choices; + @NotNull(message = "may not be null when choices is set to 'Other'.", groups = OtherChoiceValidation.class) + private String other; - public void setChoices(Set<E> choices) { - this.choices = choices; - } - - public String getOther() { - return other; - } - - public void setOther(String other) { - this.other = other; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; + public Set<E> getChoices() { + return choices; } - if (obj == null || getClass() != obj.getClass()) { - return false; + + public void setChoices(Set<E> choices) { + this.choices = choices; } - MultiChoiceOrOtherDto<?> that = (MultiChoiceOrOtherDto<?>) obj; + public String getOther() { + return other; + } - return choices != null ? choices.equals(that.choices) - : that.choices == null && (other != null ? other.equals(that.other) : that.other == null); + public void setOther(String other) { + this.other = other; + } - } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + MultiChoiceOrOtherDto<?> that = (MultiChoiceOrOtherDto<?>) obj; + return choices != null ? choices.equals(that.choices) + : that.choices == null && (other != null ? other.equals(that.other) : that.other == null); + } - @Override - public int hashCode() { - int result = choices != null ? choices.hashCode() : 0; - result = 31 * result + (other != null ? other.hashCode() : 0); - return result; - } + @Override + public int hashCode() { + int result = choices != null ? choices.hashCode() : 0; + result = 31 * result + (other != null ? other.hashCode() : 0); + return result; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelActionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelActionRequestDto.java index 68e0fd8552..53be21f0bc 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelActionRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelActionRequestDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,33 +17,30 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; import org.openecomp.sdcrests.item.types.SubmitRequestDto; public class VendorLicenseModelActionRequestDto { - private VendorLicenseModelAction action; - private SubmitRequestDto submitRequest; + private VendorLicenseModelAction action; + private SubmitRequestDto submitRequest; - public VendorLicenseModelAction getAction() { - return action; - } + public VendorLicenseModelAction getAction() { + return action; + } - public void setAction(VendorLicenseModelAction action) { - this.action = action; - } + public void setAction(VendorLicenseModelAction action) { + this.action = action; + } - public SubmitRequestDto getSubmitRequest() { - return submitRequest; - } + public SubmitRequestDto getSubmitRequest() { + return submitRequest; + } - public void setSubmitRequest(SubmitRequestDto submitRequest) { - this.submitRequest = submitRequest; - } + public void setSubmitRequest(SubmitRequestDto submitRequest) { + this.submitRequest = submitRequest; + } - public enum VendorLicenseModelAction { - Submit - } + public enum VendorLicenseModelAction {Submit} } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelEntityDto.java index 2162006c16..2c647647d8 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelEntityDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,21 +17,20 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; - import io.swagger.v3.oas.annotations.media.Schema; @Schema(description = "VendorLicenseModelEntity") public class VendorLicenseModelEntityDto extends VendorLicenseModelRequestDto { - private String id; - public String getId() { - return id; - } + private String id; + + public String getId() { + return id; + } - public void setId(String id) { - this.id = id; - } + public void setId(String id) { + this.id = id; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelRequestDto.java index da2a3e742d..625cc721a9 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/VendorLicenseModelRequestDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,48 +17,45 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types; - - import io.swagger.v3.oas.annotations.media.Schema; - import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; @Schema(description = "VendorLicenseModelRequest") public class VendorLicenseModelRequestDto { - @NotNull - @Size(max = 25) - private String vendorName; - @NotNull - @Size(max = 1000) - private String description; - @NotNull - private String iconRef; - - public String getVendorName() { - return vendorName; - } - - public void setVendorName(String vendorName) { - this.vendorName = vendorName; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getIconRef() { - return iconRef; - } - public void setIconRef(String iconRef) { - this.iconRef = iconRef; - } + @NotNull + @Size(max = 25) + private String vendorName; + @NotNull + @Size(max = 1000) + private String description; + @NotNull + private String iconRef; + + public String getVendorName() { + return vendorName; + } + + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getIconRef() { + return iconRef; + } + + public void setIconRef(String iconRef) { + this.iconRef = iconRef; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/ChoiceOrOtherSequenceProvider.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/ChoiceOrOtherSequenceProvider.java index 8be0ba3231..d2cc51c769 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/ChoiceOrOtherSequenceProvider.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/ChoiceOrOtherSequenceProvider.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,29 +17,23 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types.validation; +import java.util.ArrayList; +import java.util.List; import org.hibernate.validator.spi.group.DefaultGroupSequenceProvider; import org.openecomp.sdc.vendorlicense.dao.types.ChoiceOrOther; import org.openecomp.sdcrests.vendorlicense.types.ChoiceOrOtherDto; -import java.util.ArrayList; -import java.util.List; - -public class ChoiceOrOtherSequenceProvider - implements DefaultGroupSequenceProvider<ChoiceOrOtherDto> { +public class ChoiceOrOtherSequenceProvider implements DefaultGroupSequenceProvider<ChoiceOrOtherDto> { - @Override - public List<Class<?>> getValidationGroups(ChoiceOrOtherDto choiceOrOther) { - List<Class<?>> sequence = new ArrayList<>(); - sequence.add(ChoiceOrOtherDto.class); - - if (choiceOrOther != null && choiceOrOther.getChoice() != null - && ChoiceOrOther.OTHER_ENUM_VALUE.equals(choiceOrOther.getChoice().name())) { - sequence.add(OtherChoiceValidation.class); + @Override + public List<Class<?>> getValidationGroups(ChoiceOrOtherDto choiceOrOther) { + List<Class<?>> sequence = new ArrayList<>(); + sequence.add(ChoiceOrOtherDto.class); + if (choiceOrOther != null && choiceOrOther.getChoice() != null && ChoiceOrOther.OTHER_ENUM_VALUE.equals(choiceOrOther.getChoice().name())) { + sequence.add(OtherChoiceValidation.class); + } + return sequence; } - - return sequence; - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/MultiChoiceOrOtherSequenceProvider.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/MultiChoiceOrOtherSequenceProvider.java index 7cc9bbd2a2..446a7c2ec7 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/MultiChoiceOrOtherSequenceProvider.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/MultiChoiceOrOtherSequenceProvider.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,31 +17,24 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types.validation; +import java.util.ArrayList; +import java.util.List; import org.hibernate.validator.spi.group.DefaultGroupSequenceProvider; import org.openecomp.sdc.vendorlicense.dao.types.MultiChoiceOrOther; import org.openecomp.sdcrests.vendorlicense.types.MultiChoiceOrOtherDto; -import java.util.ArrayList; -import java.util.List; - -public class MultiChoiceOrOtherSequenceProvider - implements DefaultGroupSequenceProvider<MultiChoiceOrOtherDto> { +public class MultiChoiceOrOtherSequenceProvider implements DefaultGroupSequenceProvider<MultiChoiceOrOtherDto> { - @Override - public List<Class<?>> getValidationGroups(MultiChoiceOrOtherDto multiChoiceOrOther) { - List<Class<?>> sequence = new ArrayList<>(); - sequence.add(MultiChoiceOrOtherDto.class); - - if (multiChoiceOrOther != null && multiChoiceOrOther.getChoices() != null - && multiChoiceOrOther.getChoices().size() == 1 - && MultiChoiceOrOther.OTHER_ENUM_VALUE - .equals((((Enum) (multiChoiceOrOther.getChoices().iterator().next())).name()))) { - sequence.add(OtherChoiceValidation.class); + @Override + public List<Class<?>> getValidationGroups(MultiChoiceOrOtherDto multiChoiceOrOther) { + List<Class<?>> sequence = new ArrayList<>(); + sequence.add(MultiChoiceOrOtherDto.class); + if (multiChoiceOrOther != null && multiChoiceOrOther.getChoices() != null && multiChoiceOrOther.getChoices().size() == 1 + && MultiChoiceOrOther.OTHER_ENUM_VALUE.equals((((Enum) (multiChoiceOrOther.getChoices().iterator().next())).name()))) { + sequence.add(OtherChoiceValidation.class); + } + return sequence; } - - return sequence; - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/OtherChoiceValidation.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/OtherChoiceValidation.java index ff682dd8b5..7bffee5749 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/OtherChoiceValidation.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/src/main/java/org/openecomp/sdcrests/vendorlicense/types/validation/OtherChoiceValidation.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,8 +17,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorlicense.types.validation; public interface OtherChoiceValidation { + } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencies.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencies.java index bfeb476836..732167937d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencies.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencies.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,30 +17,35 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyResponseDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyResponseDto; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/component-dependencies") @Produces(MediaType.APPLICATION_JSON) @@ -49,54 +54,41 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface ComponentDependencies extends VspEntities { - @POST - @Path("/") - @Operation( description= "Create a vendor software product component dependency") - Response create(@Valid ComponentDependencyModel request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product component dependency") + Response create(@Valid ComponentDependencyModel request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/") - @Operation(description = "Get component dependencies for vendor software product", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation = ComponentDependencyResponseDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") - String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/") + @Operation(description = "Get component dependencies for vendor software product", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ComponentDependencyResponseDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{dependencyId}") - @Operation(description = "Delete component dependency for vendor software product") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") - @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product Component Dependency Id") @PathParam - ("dependencyId") String dependencyId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/{dependencyId}") + @Operation(description = "Delete component dependency for vendor software product") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product Component Dependency Id") @PathParam("dependencyId") String dependencyId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{dependencyId}") - @Operation(description = "Update component dependency for vendor software product") - Response update(@Valid ComponentDependencyModel request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") - String versionId, - @Parameter(description = "Vendor software product Component Dependency Id") @PathParam - ("dependencyId") String dependencyId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @PUT + @Path("/{dependencyId}") + @Operation(description = "Update component dependency for vendor software product") + Response update(@Valid ComponentDependencyModel request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product Component Dependency Id") @PathParam("dependencyId") String dependencyId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{dependencyId}") - @Operation(description = "Get component dependency for vendor software product", responses = @ApiResponse(content = @Content(schema = @Schema(implementation =ComponentDependencyResponseDto.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product Component Dependency Id") @PathParam - ("dependencyId") String dependencyId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{dependencyId}") + @Operation(description = "Get component dependency for vendor software product", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ComponentDependencyResponseDto.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product Component Dependency Id") @PathParam("dependencyId") String dependencyId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentMonitoringUploads.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentMonitoringUploads.java index f575991456..1a34bfc47c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentMonitoringUploads.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentMonitoringUploads.java @@ -17,73 +17,67 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.openecomp.sdcrests.vendorsoftwareproducts.types.MonitoringUploadStatusDto; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - -@Path( - "/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/uploads/") +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/uploads/") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Product Component Uploads")}) @Validated public interface ComponentMonitoringUploads extends VspEntities { - @POST - @Path("types/{type}/") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Operation(description = "Upload file for component by type") - Response upload(@Multipart("upload") Attachment attachment, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") - String vspId, - @Parameter(description = "Vendor software product version Id") - @PathParam("versionId") String versionId, - @Parameter(description = "Component Id") @PathParam("componentId") String - componentId, - @Parameter(description = "Upload Type") @PathParam("type") String type, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; - @DELETE - @Path("types/{type}") - @Operation(description = "Delete file uploaded for component") - Response delete( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") - String versionId, - @Parameter(description = "Component Id") @PathParam("componentId") String componentId, - @Parameter(description = "Upload Type") @PathParam("type") String type, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws Exception; + @POST + @Path("types/{type}/") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Operation(description = "Upload file for component by type") + Response upload(@Multipart("upload") Attachment attachment, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Upload Type") @PathParam("type") String type, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; + + @DELETE + @Path("types/{type}") + @Operation(description = "Delete file uploaded for component") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Upload Type") @PathParam("type") String type, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; - @GET - @Path("") - @Operation(description = "Get the filenames of uploaded files by type", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation =MonitoringUploadStatusDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") - String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("") + @Operation(description = "Get the filenames of uploaded files by type", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = MonitoringUploadStatusDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java index b5907d5d30..3289238eb5 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java @@ -17,145 +17,124 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import java.util.List; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/processes") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Product Component Processes")}) @Validated public interface ComponentProcesses extends VspEntities { - @GET - @Path("/") - @Operation(description = "List vendor software product component processes", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ProcessEntityDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - - @DELETE - @Path("/") - @Operation(description = "Delete vendor software product processes",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = List.class)))) - Response deleteList( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/") - @Operation(description = "Create a vendor software product process") - Response create(@Valid ProcessRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @GET + @Path("/") + @Operation(description = "List vendor software product component processes", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ProcessEntityDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{processId}") - @Operation(description = "Get vendor software product process",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ProcessEntityDto.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/") + @Operation(description = "Delete vendor software product processes", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = List.class)))) + Response deleteList(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{processId}") - @Operation(description = "Delete vendor software product process") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product process") + Response create(@Valid ProcessRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{processId}") - @Operation(description = "Update vendor software product process") - Response update(@Valid ProcessRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{processId}") + @Operation(description = "Get vendor software product process", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ProcessEntityDto.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @DELETE + @Path("/{processId}") + @Operation(description = "Delete vendor software product process") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{processId}") + @Operation(description = "Update vendor software product process") + Response update(@Valid ProcessRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{processId}/upload") - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Operation(description = "Get vendor software product process uploaded file") - Response getUploadedFile( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{processId}/upload") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Operation(description = "Get vendor software product process uploaded file") + Response getUploadedFile(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{processId}/upload") - @Operation(description = "Delete vendor software product process uploaded file") - Response deleteUploadedFile( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{processId}/upload") + @Operation(description = "Delete vendor software product process uploaded file") + Response deleteUploadedFile(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/{processId}/upload") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Operation(description = "Update vendor software product process upload") - Response uploadFile(@Multipart("upload") Attachment attachment, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product process Id") - @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/{processId}/upload") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Operation(description = "Update vendor software product process upload") + Response uploadFile(@Multipart("upload") Attachment attachment, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Components.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Components.java index fa0ecbdcbe..ccad46bb3e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Components.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Components.java @@ -17,18 +17,33 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto; @@ -36,99 +51,72 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponse import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import java.util.List; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Product Components")}) @Validated public interface Components extends VspEntities { - @GET - @Path("/") - @Operation(description = "List vendor software product components", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ComponentDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - - @DELETE - @Path("/") - @Operation(description = "Delete vendor software product components", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = List.class)))) - Response deleteList( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/") - @Operation(description = "Create a vendor software product component") - Response create(@Valid ComponentRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @GET + @Path("/") + @Operation(description = "List vendor software product components", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ComponentDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{componentId}") - @Operation(description = "Get vendor software product component", responses = @ApiResponse(content = @Content(schema = @Schema(implementation =ComponentData.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/") + @Operation(description = "Delete vendor software product components", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = List.class)))) + Response deleteList(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{componentId}") - @Operation(description = "Delete vendor software product component") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product component") + Response create(@Valid ComponentRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{componentId}") - @Operation(description = "Update vendor software product component") - Response update(@Valid ComponentRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{componentId}") + @Operation(description = "Get vendor software product component", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ComponentData.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @DELETE + @Path("/{componentId}") + @Operation(description = "Delete vendor software product component") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{componentId}") + @Operation(description = "Update vendor software product component") + Response update(@Valid ComponentRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{componentId}/questionnaire") - @Operation(description = "Get vendor software product component questionnaire",responses = @ApiResponse(content = @Content(schema = @Schema(implementation =QuestionnaireResponseDto.class)))) - Response getQuestionnaire( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{componentId}/questionnaire") + @Operation(description = "Get vendor software product component questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) + Response getQuestionnaire(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{componentId}/questionnaire") - @Operation(description = "Update vendor software product component questionnaire") - Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") - String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") - String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{componentId}/questionnaire") + @Operation(description = "Update vendor software product component questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Compute.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Compute.java index ded4327dd2..666fad5ea3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Compute.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Compute.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,125 +17,104 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDetailsDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - -@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId" + - "}/compute-flavors") +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId" + "}/compute-flavors") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Product Component Compute-flavors")}) @Validated public interface Compute extends VspEntities { - @GET - @Path("/") - @Operation(description = "Get list of vendor software product component compute-flavors", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation =ComputeDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/") + @Operation(description = "Get list of vendor software product component compute-flavors", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ComputeDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{computeFlavorId}") - @Operation(description = "Get vendor software product component compute-flavor", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation =ComputeDetailsDto.class))))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product compute-flavor Id") @PathParam - ("computeFlavorId") - String computeId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{computeFlavorId}") + @Operation(description = "Get vendor software product component compute-flavor", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ComputeDetailsDto.class))))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product compute-flavor Id") @PathParam("computeFlavorId") String computeId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/") - @Operation(description = "Create a vendor software product component compute-flavor") - Response create(@Valid ComputeDetailsDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product component compute-flavor") + Response create(@Valid ComputeDetailsDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{computeFlavorId}") - @Operation(description = "Update vendor software product component compute-flavor") - Response update(@Valid ComputeDetailsDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product compute-flavor Id") @PathParam - ("computeFlavorId") - String computeFlavorId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @PUT + @Path("/{computeFlavorId}") + @Operation(description = "Update vendor software product component compute-flavor") + Response update(@Valid ComputeDetailsDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product compute-flavor Id") @PathParam("computeFlavorId") String computeFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{computeFlavorId}/questionnaire") - @Operation(description = "Update vendor software product component compute-flavor questionnaire") - Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product compute-flavor Id") @PathParam - ("computeFlavorId") - String computeFlavorId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @PUT + @Path("/{computeFlavorId}/questionnaire") + @Operation(description = "Update vendor software product component compute-flavor questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product compute-flavor Id") @PathParam("computeFlavorId") String computeFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{computeFlavorId}") - @Operation(description = "Delete vendor software product component compute-flavor") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product compute-flavor Id") @PathParam - ("computeFlavorId") - String computeFlavorId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/{computeFlavorId}") + @Operation(description = "Delete vendor software product component compute-flavor") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product compute-flavor Id") @PathParam("computeFlavorId") String computeFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{computeFlavorId}/questionnaire") - @Operation(description = "Get vendor software product component compute-flavor questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation =QuestionnaireResponseDto.class)))) - Response getQuestionnaire( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product compute-flavor Id") @PathParam - ("computeFlavorId") String computeId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{computeFlavorId}/questionnaire") + @Operation(description = "Get vendor software product component compute-flavor questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) + Response getQuestionnaire(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product compute-flavor Id") @PathParam("computeFlavorId") String computeId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/DeploymentFlavors.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/DeploymentFlavors.java index 7d74044645..4312b10ab3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/DeploymentFlavors.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/DeploymentFlavors.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,32 +17,36 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorListResponseDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorRequestDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorListResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorRequestDto; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/deployment-flavors") @Produces(MediaType.APPLICATION_JSON) @@ -51,59 +55,49 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface DeploymentFlavors extends VspEntities { - @POST - @Path("/") - @Operation(description = "Create a vendor software product Deployment Flavor") - Response create(@Valid DeploymentFlavorRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @POST + @Path("/") + @Operation(description = "Create a vendor software product Deployment Flavor") + Response create(@Valid DeploymentFlavorRequestDto request, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/") + @Operation(description = "List vendor software product Deployment Flavor", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = DeploymentFlavorListResponseDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/") - @Operation(description = "List vendor software product Deployment Flavor", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = DeploymentFlavorListResponseDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{deploymentFlavorId}") + @Operation(description = "Get vendor software product Deployment Flavor", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = DeploymentFlavorDto.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product Deployment Flavor Id") @PathParam("deploymentFlavorId") String deploymentFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{deploymentFlavorId}") - @Operation(description = "Get vendor software product Deployment Flavor",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = DeploymentFlavorDto.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product Deployment Flavor Id") @PathParam - ("deploymentFlavorId") String deploymentFlavorId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/schema") + Response getSchema(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/schema") - Response getSchema(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String - vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/{deploymentFlavorId}") + @Operation(description = "Delete vendor software product Deployment Flavor") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product Deployment Flavor Id") @PathParam("deploymentFlavorId") String deploymentFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{deploymentFlavorId}") - @Operation(description = "Delete vendor software product Deployment Flavor") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product Deployment Flavor Id") - @PathParam("deploymentFlavorId") String deploymentFlavorId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - - @PUT - @Path("/{deploymentFlavorId}") - @Operation(description = "Update vendor software product Deployment Flavor") - Response update(@Valid DeploymentFlavorRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product Deployment Flavor Id") - @PathParam("deploymentFlavorId") String deploymentFlavorId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @PUT + @Path("/{deploymentFlavorId}") + @Operation(description = "Update vendor software product Deployment Flavor") + Response update(@Valid DeploymentFlavorRequestDto request, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product Deployment Flavor Id") @PathParam("deploymentFlavorId") String deploymentFlavorId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Images.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Images.java index 49a25ed273..f480405e45 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Images.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Images.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,33 +17,38 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageRequestDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/images") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -51,117 +56,90 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface Images extends VspEntities { - @GET - @Path("/") - @Operation(description = "List vendor software product component images",responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ImageDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - - @POST - @Path("/") - @Operation(description = "Create a vendor software product component image") - Response create(@Valid ImageRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @GET + @Path("/") + @Operation(description = "List vendor software product component images", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ImageDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/schema") - //@Operation(description = "Get schema for vendor software product component Image" , - // response = QuestionnaireResponseDto.class) - Response getImageSchema(@Parameter(description = "Vendor software product Id") @PathParam("vspId") - String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId,@NotNull - (message = USER_MISSING_ERROR_MSG) @HeaderParam - (USER_ID_HEADER_PARAM) String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product component image") + Response create(@Valid ImageRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - /*@GET - @Path("/{imageId}") - @Operation(description = "Get vendor software product component Image", - response = ImageDto.class, - responseContainer = "ImageEntityResponse") - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product image Id") @PathParam("imageId") - String imageId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user);*/ + @GET + @Path("/schema") + //@Operation(description = "Get schema for vendor software product component Image" , - @GET - @Path("/{imageId}") - @Operation(description = "Get vendor software product component Image",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ImageDto.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product Image Id") @PathParam - ("imageId") - String imageId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + // response = QuestionnaireResponseDto.class) + Response getImageSchema(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{imageId}") - @Operation(description = "Delete vendor software product Image") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product Image Id") @PathParam("imageId") - String imageId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + /*@GET + @Path("/{imageId}") + @Operation(description = "Get vendor software product component Image", + response = ImageDto.class, + responseContainer = "ImageEntityResponse") + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") + String componentId, + @Parameter(description = "Vendor software product image Id") @PathParam("imageId") + String imageId, + @Pattern(regexp = Version.VERSION_REGEX, + message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") + String version, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user);*/ + @GET + @Path("/{imageId}") + @Operation(description = "Get vendor software product component Image", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ImageDto.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product Image Id") @PathParam("imageId") String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{imageId}") - @Operation(description = "Update vendor software product Image") - Response update(@Valid ImageRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product Image Id") @PathParam("imageId") - String imageId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/{imageId}") + @Operation(description = "Delete vendor software product Image") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product Image Id") @PathParam("imageId") String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{imageId}") + @Operation(description = "Update vendor software product Image") + Response update(@Valid ImageRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product Image Id") @PathParam("imageId") String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{imageId}/questionnaire") - @Operation(description = "Update vendor software product component image questionnaire") - Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, - @Parameter(description = "Vendor software product Id") - @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") - @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product image Id") - @PathParam ("imageId") String imageId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{imageId}/questionnaire") + @Operation(description = "Update vendor software product component image questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product image Id") @PathParam("imageId") String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{imageId}/questionnaire") - @Operation(description = "Get vendor software product component image questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) - Response getQuestionnaire( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product image Id") @PathParam - ("imageId") String imageId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{imageId}/questionnaire") + @Operation(description = "Get vendor software product component image questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) + Response getQuestionnaire(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product image Id") @PathParam("imageId") String imageId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Networks.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Networks.java index f269832d6b..b2e356c23d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Networks.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Networks.java @@ -17,30 +17,35 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkRequestDto; -import org.springframework.validation.annotation.Validated; - import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkRequestDto; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/networks") @Produces(MediaType.APPLICATION_JSON) @@ -48,51 +53,42 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Product Networks")}) @Validated public interface Networks extends VspEntities { - @GET - @Path("/") - @Operation(description = "List vendor software product networks",responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = NetworkDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - @POST - @Path("/") - @Operation(description = "Create a vendor software product network") - Response create(@Valid NetworkRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @GET + @Path("/") + @Operation(description = "List vendor software product networks", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = NetworkDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{networkId}") - @Operation(description = "Get vendor software product network",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = NetworkDto.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product network Id") - @PathParam("networkId") String networkId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product network") + Response create(@Valid NetworkRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{networkId}") - @Operation(description = "Delete vendor software product network") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product network Id") @PathParam("networkId") - String networkId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{networkId}") + @Operation(description = "Get vendor software product network", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = NetworkDto.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product network Id") @PathParam("networkId") String networkId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{networkId}") - @Operation(description = "Update vendor software product network") - Response update(@Valid NetworkRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product network Id") @PathParam("networkId") - String networkId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/{networkId}") + @Operation(description = "Delete vendor software product network") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product network Id") @PathParam("networkId") String networkId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{networkId}") + @Operation(description = "Update vendor software product network") + Response update(@Valid NetworkRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product network Id") @PathParam("networkId") String networkId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java index c50c593fce..8d0b8ca617 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,118 +17,104 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicRequestDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/nics") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Product Component NICs")}) @Validated public interface Nics extends VspEntities { - @GET - @Path("/") - @Operation(description = "List vendor software product component NICs",responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = NicDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - @POST - @Path("/") - @Operation(description = "Create a vendor software product NIC") - Response create(@Valid NicRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @GET + @Path("/") + @Operation(description = "List vendor software product component NICs", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = NicDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{nicId}") - @Operation(description = "Get vendor software product NIC", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = NicDto.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") String nicId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product NIC") + Response create(@Valid NicRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{nicId}") - @Operation(description = "Delete vendor software product NIC") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") - String nicId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{nicId}") + @Operation(description = "Get vendor software product NIC", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = NicDto.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") String nicId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{nicId}") - @Operation(description = "Update vendor software product NIC") - Response update(@Valid NicRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") - String nicId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/{nicId}") + @Operation(description = "Delete vendor software product NIC") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") String nicId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{nicId}") + @Operation(description = "Update vendor software product NIC") + Response update(@Valid NicRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") String nicId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{nicId}/questionnaire") - @Operation(description = "Get vendor software product component NIC questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) - Response getQuestionnaire( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") String nicId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{nicId}/questionnaire") + @Operation(description = "Get vendor software product component NIC questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) + Response getQuestionnaire(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") String nicId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{nicId}/questionnaire") - @Operation(description = "Update vendor software product component NIC questionnaire") - Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") - String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product component Id") - @PathParam("componentId") String componentId, - @Parameter(description = "Vendor software product NIC Id") - @PathParam("nicId") String nicId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @PUT + @Path("/{nicId}/questionnaire") + @Operation(description = "Update vendor software product component NIC questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product component Id") @PathParam("componentId") String componentId, + @Parameter(description = "Vendor software product NIC Id") @PathParam("nicId") String nicId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java index 5d99e2dc84..23c8ef2481 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java @@ -13,35 +13,40 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.openecomp.sdcrests.vendorsoftwareproducts.types.FileDataStructureDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/orchestration-template-candidate") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -49,60 +54,44 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface OrchestrationTemplateCandidate extends VspEntities { - @POST - @Path("/") - @Consumes(MediaType.MULTIPART_FORM_DATA) - Response upload( - @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Multipart("upload") Attachment fileToUpload, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @POST + @Path("/") + @Consumes(MediaType.MULTIPART_FORM_DATA) + Response upload(@PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Multipart("upload") Attachment fileToUpload, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/") - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Operation(description = "Get uploaded Network Package file", - summary = "Downloads in uploaded Network Package file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation =File.class)))) - Response get( - @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws IOException; + @GET + @Path("/") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Operation(description = "Get uploaded Network Package file", summary = "Downloads in uploaded Network Package file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class)))) + Response get(@PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws IOException; - @DELETE - @Path("/") - @Operation(description = "Delete orchestration template candidate file and its files data structure") - Response abort( - @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId) - throws Exception; + @DELETE + @Path("/") + @Operation(description = "Delete orchestration template candidate file and its files data structure") + Response abort(@PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId) + throws Exception; - @PUT - @Path("/process") - @Operation(description = "process Orchestration Template Candidate",responses = @ApiResponse(content = @Content(schema = @Schema(implementation =UploadFileResponseDto.class)))) - Response process( - @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws InvocationTargetException, IllegalAccessException; + @PUT + @Path("/process") + @Operation(description = "process Orchestration Template Candidate", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = UploadFileResponseDto.class)))) + Response process(@PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws InvocationTargetException, IllegalAccessException; - @PUT - @Path("/manifest") - @Operation(description = "Update an existing vendor software product") - Response updateFilesDataStructure( - @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @Valid FileDataStructureDto fileDataStructureDto, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws Exception; + @PUT + @Path("/manifest") + @Operation(description = "Update an existing vendor software product") + Response updateFilesDataStructure(@PathParam("vspId") String vspId, + @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @Valid FileDataStructureDto fileDataStructureDto, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; - @GET - @Path("/manifest") - @Operation(description = "Get uploaded HEAT file files data structure", - summary = "Downloads the latest HEAT package",responses = @ApiResponse(content = @Content(schema = @Schema(implementation =FileDataStructureDto.class)))) - Response getFilesDataStructure( - @PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws Exception; + @GET + @Path("/manifest") + @Operation(description = "Get uploaded HEAT file files data structure", summary = "Downloads the latest HEAT package", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = FileDataStructureDto.class)))) + Response getFilesDataStructure(@PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java index 27195e1cbb..5f4c6496ec 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,127 +17,115 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; +import java.util.List; +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; import org.springframework.validation.annotation.Validated; -import javax.validation.Valid; -import javax.validation.constraints.NotNull; -import javax.ws.rs.*; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import java.util.List; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - @Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/processes") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Tags({@Tag(name = "SDCE-1 APIs"), @Tag(name = "Vendor Software Product Processes")}) @Validated public interface Processes { - @GET - @Path("/") - @Operation(description = "List vendor software product processes", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ProcessEntityDto.class))))) - Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); - - @DELETE - @Path("/") - @Operation(description = "Delete vendor software product processes", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = List.class)))) - Response deleteList( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/") - @Operation(description = "Create a vendor software product process") - Response create(@Valid ProcessRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @GET + @Path("/") + @Operation(description = "List vendor software product processes", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = ProcessEntityDto.class))))) + Response list(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{processId}") - @Operation(description = "Get vendor software product process", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ProcessEntityDto.class)))) - Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @DELETE + @Path("/") + @Operation(description = "Delete vendor software product processes", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = List.class)))) + Response deleteList(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{processId}") - @Operation(description = "Delete vendor software product process") - Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/") + @Operation(description = "Create a vendor software product process") + Response create(@Valid ProcessRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @PUT - @Path("/{processId}") - @Operation(description = "Update vendor software product process") - Response update(@Valid ProcessRequestDto request, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @GET + @Path("/{processId}") + @Operation(description = "Get vendor software product process", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ProcessEntityDto.class)))) + Response get(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @DELETE + @Path("/{processId}") + @Operation(description = "Delete vendor software product process") + Response delete(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{processId}") + @Operation(description = "Update vendor software product process") + Response update(@Valid ProcessRequestDto request, @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/{processId}/upload") - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Operation(description = "Get vendor software product process uploaded file") - Response getUploadedFile( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{processId}/upload") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Operation(description = "Get vendor software product process uploaded file") + Response getUploadedFile(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @DELETE - @Path("/{processId}/upload") - @Operation(description = "Delete vendor software product process uploaded file") - Response deleteUploadedFile( - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product process Id") @PathParam("processId") - String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + @DELETE + @Path("/{processId}/upload") + @Operation(description = "Delete vendor software product process uploaded file") + Response deleteUploadedFile(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("/{processId}/upload") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Operation(description = "Update vendor software product process upload") - Response uploadFile(@Multipart("upload") Attachment attachment, - @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, - @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, - @Parameter(description = "Vendor software product process Id") - @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) - String user); + @POST + @Path("/{processId}/upload") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Operation(description = "Update vendor software product process upload") + Response uploadFile(@Multipart("upload") Attachment attachment, + @Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @Parameter(description = "Vendor software product version Id") @PathParam("versionId") String versionId, + @Parameter(description = "Vendor software product process Id") @PathParam("processId") String processId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java index af9953ae69..328c96254f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java @@ -13,35 +13,45 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.openecomp.sdcrests.vsp.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.item.types.ItemCreationDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; -import org.springframework.validation.annotation.Validated; - +import java.io.File; +import java.io.IOException; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.File; -import java.io.IOException; -import java.util.List; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +import org.openecomp.sdcrests.item.types.ItemCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/vendor-software-products") @Produces(MediaType.APPLICATION_JSON) @@ -50,145 +60,105 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface VendorSoftwareProducts extends VspEntities { - @POST - @Path("/") - @Operation(description = "Create a new vendor software product",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ItemCreationDto.class)))) - Response createVsp(@Valid VspRequestDto vspRequestDto, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @GET - @Path("/") - @Operation(description = "Get list of vendor software products and their description",responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = VspDetailsDto.class))))) - Response listVsps(@Parameter(description = "Filter to return only Vendor Software Products with at" + - " least one version at this status. Currently supported values: 'Certified' , 'Draft'") - @QueryParam("versionFilter") String versionStatus, - @Parameter(description = "Filter to only return Vendor Software Products at this status." + - "Currently supported values: 'ACTIVE' , 'ARCHIVED'." + - "Default value = 'ACTIVE'.") - @QueryParam("Status") String itemStatus, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @GET - @Path("/{vspId}/versions/{versionId}") - @Parameter(description = "Get details of a vendor software product") - Response getVsp(@PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @PUT - @Path("/{vspId}/versions/{versionId}") - @Parameter(description = "Update an existing vendor software product") - Response updateVsp(@PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @Valid VspDescriptionDto vspDescriptionDto, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @DELETE - @Path("/{vspId}") - @Parameter(description = "Deletes vendor software product by given id") - Response deleteVsp(@PathParam("vspId") String vspId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @GET - @Path("/packages") - @Operation(description = "Get list of translated CSAR files details", responses = @ApiResponse(content = @Content(array = @ArraySchema( schema = @Schema(implementation=PackageInfoDto.class))))) - Response listPackages(@Parameter(description = "Vendor Software Product status filter. " + - "Currently supported values: 'ACTIVE', 'ARCHIVED'") - @QueryParam("Status") String status, - @Parameter(description = "Category") @QueryParam("category") String category, - @Parameter(description = "Sub-category") @QueryParam("subCategory") String subCategory, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @GET - @Path("/{vspId}/versions/{versionId}/orchestration-template") - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Operation(description = "Get Orchestration Template (HEAT) file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation=File.class)))) - Response getOrchestrationTemplate( - @PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - - @GET - @Path("/validation-vsp") - Response getValidationVsp( - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws Exception; - - @PUT - @Path("/{vspId}/versions/{versionId}/actions") - @Operation(description = "Actions on a vendor software product", - summary = "Performs one of the following actions on a vendor software product: |" - + "Checkout: Locks it for edits by other users. Only the locking user sees the edited " - + "version.|" - + "Undo_Checkout: Unlocks it and deletes the edits that were done.|" - + "Checkin: Unlocks it and activates the edited version to all users.| " - + "Submit: Finalize its active version.|" - + "Create_Package: Creates a CSAR zip file.|") - Response actOnVendorSoftwareProduct(VersionSoftwareProductActionRequestDto request, - @PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user) - throws IOException; - - @GET - @Path("/packages/{vspId}") - @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Operation(description = "Get translated CSAR file", - summary = "Exports translated file to a zip file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation=File.class)))) - Response getTranslatedFile(@PathParam("vspId") String vspId, - @QueryParam("versionId") String versionId, - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @GET - @Path("/{vspId}/versions/{versionId}/questionnaire") - @Operation(description = "Get vendor software product questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation=QuestionnaireResponseDto.class)))) - Response getQuestionnaire(@PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @PUT - @Path("/{vspId}/versions/{versionId}/questionnaire") - @Operation(description = "Update vendor software product questionnaire") - Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, - @PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) + @POST + @Path("/") + @Operation(description = "Create a new vendor software product", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = ItemCreationDto.class)))) + Response createVsp(@Valid VspRequestDto vspRequestDto, @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/") + @Operation(description = "Get list of vendor software products and their description", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = VspDetailsDto.class))))) + Response listVsps(@Parameter(description = "Filter to return only Vendor Software Products with at" + + " least one version at this status. Currently supported values: 'Certified' , 'Draft'") @QueryParam("versionFilter") String versionStatus, + @Parameter(description = "Filter to only return Vendor Software Products at this status." + + "Currently supported values: 'ACTIVE' , 'ARCHIVED'." + + "Default value = 'ACTIVE'.") @QueryParam("Status") String itemStatus, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{vspId}/versions/{versionId}") + @Parameter(description = "Get details of a vendor software product") + Response getVsp(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{vspId}/versions/{versionId}") + @Parameter(description = "Update an existing vendor software product") + Response updateVsp(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, @Valid VspDescriptionDto vspDescriptionDto, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @DELETE + @Path("/{vspId}") + @Parameter(description = "Deletes vendor software product by given id") + Response deleteVsp(@PathParam("vspId") String vspId, @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/packages") + @Operation(description = "Get list of translated CSAR files details", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = PackageInfoDto.class))))) + Response listPackages(@Parameter(description = "Vendor Software Product status filter. " + + "Currently supported values: 'ACTIVE', 'ARCHIVED'") @QueryParam("Status") String status, + @Parameter(description = "Category") @QueryParam("category") String category, + @Parameter(description = "Sub-category") @QueryParam("subCategory") String subCategory, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{vspId}/versions/{versionId}/orchestration-template") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Operation(description = "Get Orchestration Template (HEAT) file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class)))) + Response getOrchestrationTemplate(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/validation-vsp") + Response getValidationVsp(@NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; + + @PUT + @Path("/{vspId}/versions/{versionId}/actions") + @Operation(description = "Actions on a vendor software product", summary = "Performs one of the following actions on a vendor software product: |" + + "Checkout: Locks it for edits by other users. Only the locking user sees the edited " + "version.|" + + "Undo_Checkout: Unlocks it and deletes the edits that were done.|" + "Checkin: Unlocks it and activates the edited version to all users.| " + + "Submit: Finalize its active version.|" + "Create_Package: Creates a CSAR zip file.|") + Response actOnVendorSoftwareProduct(VersionSoftwareProductActionRequestDto request, @PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws IOException; + + @GET + @Path("/packages/{vspId}") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @Operation(description = "Get translated CSAR file", summary = "Exports translated file to a zip file", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class)))) + Response getTranslatedFile(@PathParam("vspId") String vspId, @QueryParam("versionId") String versionId, @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @PUT - @Path("/{vspId}/versions/{versionId}/heal") - @Operation(description = "Checkout and heal vendor software product questionnaire",responses = @ApiResponse(content = @Content(schema = @Schema(implementation=QuestionnaireResponseDto.class)))) - Response heal(@PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - - @GET - @Path("/{vspId}/versions/{versionId}/vspInformationArtifact") - @Produces(MediaType.TEXT_PLAIN) - @Operation(description = "Get vendor software product information artifact for specified version",responses = @ApiResponse(content = @Content(schema = @Schema(implementation=File.class)))) - Response getVspInformationArtifact(@PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - @GET - @Path("/{vspId}/versions/{versionId}/compute-flavors") - @Operation(description = "Get list of vendor software product compute-flavors", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation=VspComputeDto.class))))) - Response listComputes(@Parameter(description = "Vendor software product Id") - @PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/{vspId}/versions/{versionId}/questionnaire") + @Operation(description = "Get vendor software product questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) + Response getQuestionnaire(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{vspId}/versions/{versionId}/questionnaire") + @Operation(description = "Update vendor software product questionnaire") + Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, @PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @PUT + @Path("/{vspId}/versions/{versionId}/heal") + @Operation(description = "Checkout and heal vendor software product questionnaire", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = QuestionnaireResponseDto.class)))) + Response heal(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{vspId}/versions/{versionId}/vspInformationArtifact") + @Produces(MediaType.TEXT_PLAIN) + @Operation(description = "Get vendor software product information artifact for specified version", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class)))) + Response getVspInformationArtifact(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/{vspId}/versions/{versionId}/compute-flavors") + @Operation(description = "Get list of vendor software product compute-flavors", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = VspComputeDto.class))))) + Response listComputes(@Parameter(description = "Vendor software product Id") @PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProductsForSwaggerFileUpload.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProductsForSwaggerFileUpload.java index cc94725501..70de99035b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProductsForSwaggerFileUpload.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProductsForSwaggerFileUpload.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,28 +17,30 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + import com.sun.jersey.multipart.FormDataParam; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; -import org.springframework.validation.annotation.Validated; - +import java.io.InputStream; import javax.validation.constraints.NotNull; -import javax.ws.rs.*; +import javax.ws.rs.Consumes; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.InputStream; - -import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; +import org.springframework.validation.annotation.Validated; @Path("/v1.0/vendor-software-products") @Produces(MediaType.APPLICATION_JSON) @@ -47,17 +49,11 @@ import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG @Validated public interface VendorSoftwareProductsForSwaggerFileUpload { - - - @POST - @Path("/{vspId}/versions/{versionId}/orchestration-template-candidate") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @Operation(description = "Uploads a HEAT package to translate",responses = @ApiResponse(content = @Content(schema = @Schema(implementation = UploadFileResponseDto.class)))) - Response uploadOrchestrationTemplateCandidate(@PathParam("vspId") String vspId, - @PathParam("versionId") String versionId, - @FormDataParam("upload") - InputStream heatFileToUpload, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_ID_HEADER_PARAM) String user); - - } + @POST + @Path("/{vspId}/versions/{versionId}/orchestration-template-candidate") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Operation(description = "Uploads a HEAT package to translate", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = UploadFileResponseDto.class)))) + Response uploadOrchestrationTemplateCandidate(@PathParam("vspId") String vspId, @PathParam("versionId") String versionId, + @FormDataParam("upload") InputStream heatFileToUpload, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VspEntities.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VspEntities.java index 4514af649b..92b0dec6e3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VspEntities.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VspEntities.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest; public interface VspEntities { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDto.java index eae59cf103..ac6b3a887f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDto.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; @@ -21,11 +20,11 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; public class MapComponentDataToComponentDto extends MappingBase<ComponentData, ComponentDto> { - @Override - public void doMapping(ComponentData source, ComponentDto target) { - target.setName(source.getName()); - target.setDisplayName( - source.getDisplayName() == null ? source.getName() : source.getDisplayName()); - target.setDescription(source.getDescription()); - } + + @Override + public void doMapping(ComponentData source, ComponentDto target) { + target.setName(source.getName()); + target.setDisplayName(source.getDisplayName() == null ? source.getName() : source.getDisplayName()); + target.setDescription(source.getDescription()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToCreationDto.java index a82902bd84..e69d6a9380 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToCreationDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,20 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; - import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyCreationDto; -public class MapComponentDependencyEntityToCreationDto extends MappingBase - <ComponentDependencyModelEntity, ComponentDependencyCreationDto> { +public class MapComponentDependencyEntityToCreationDto extends MappingBase<ComponentDependencyModelEntity, ComponentDependencyCreationDto> { - @Override - public void doMapping(ComponentDependencyModelEntity source, - ComponentDependencyCreationDto target) { - target.setId(source.getId()); - } + @Override + public void doMapping(ComponentDependencyModelEntity source, ComponentDependencyCreationDto target) { + target.setId(source.getId()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToDto.java index 1fdadcbc88..aedd06be69 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyEntityToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,22 +17,19 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyResponseDto; -public class MapComponentDependencyEntityToDto extends - MappingBase<ComponentDependencyModelEntity, ComponentDependencyResponseDto> { +public class MapComponentDependencyEntityToDto extends MappingBase<ComponentDependencyModelEntity, ComponentDependencyResponseDto> { - @Override - public void doMapping(ComponentDependencyModelEntity source, - ComponentDependencyResponseDto target) { - target.setSourceId(source.getSourceComponentId()); - target.setTargetId(source.getTargetComponentId()); - target.setRelationType(source.getRelation()); - target.setId(source.getId()); - } + @Override + public void doMapping(ComponentDependencyModelEntity source, ComponentDependencyResponseDto target) { + target.setSourceId(source.getSourceComponentId()); + target.setTargetId(source.getTargetComponentId()); + target.setRelationType(source.getRelation()); + target.setId(source.getId()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelEntityToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelEntityToDto.java index c4c54d4ed8..bcfe05da83 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelEntityToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelEntityToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,21 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; -public class MapComponentDependencyModelEntityToDto extends - MappingBase<ComponentDependencyModelEntity, ComponentDependencyModel> { +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()); - } + @Override + public void doMapping(ComponentDependencyModelEntity source, ComponentDependencyModel target) { + target.setSourceId(source.getSourceComponentId()); + target.setTargetId(source.getTargetComponentId()); + target.setRelationType(source.getRelation()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntity.java index 4988ab43ab..73ef053455 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntity.java @@ -12,11 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. -*/ - + */ package org.openecomp.sdcrests.vsp.rest.mapping; - import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; @@ -25,21 +23,18 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRelationType; -public class MapComponentDependencyModelRequestToEntity extends - MappingBase<ComponentDependencyModel, ComponentDependencyModelEntity> { +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(); - throw new CoreException(errorCode, exception); + @Override + public void doMapping(ComponentDependencyModel source, ComponentDependencyModelEntity target) { + target.setSourceComponentId(source.getSourceId()); + target.setTargetComponentId(source.getTargetId()); + try { + ComponentRelationType.valueOf(source.getRelationType()); + target.setRelation(source.getRelationType()); + } catch (IllegalArgumentException exception) { + ErrorCode errorCode = ComponentDependencyModelErrorBuilder.getInvalidRelationTypeErrorBuilder(); + throw new CoreException(errorCode, exception); + } } - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentCreationDto.java index f2f346891f..089a91694e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentCreationDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,17 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentCreationDto; -public class MapComponentEntityToComponentCreationDto extends MappingBase<ComponentEntity, - ComponentCreationDto> { - @Override - public void doMapping(ComponentEntity source, ComponentCreationDto target) { - target.setVfcId(source.getId()); - } +public class MapComponentEntityToComponentCreationDto extends MappingBase<ComponentEntity, ComponentCreationDto> { + + @Override + public void doMapping(ComponentEntity source, ComponentCreationDto target) { + target.setVfcId(source.getId()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentDto.java index 8878581d1c..e82363eae9 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentEntityToComponentDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; @@ -26,12 +25,13 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; public class MapComponentEntityToComponentDto extends MappingBase<ComponentEntity, ComponentDto> { - @Override - public void doMapping(ComponentEntity source, ComponentDto target) { - target.setId(source.getId()); - ComponentData component = source.getComponentCompositionData(); - if (component != null) { - new MapComponentDataToComponentDto().doMapping(component, target); + + @Override + public void doMapping(ComponentEntity source, ComponentDto target) { + target.setId(source.getId()); + ComponentData component = source.getComponentCompositionData(); + if (component != null) { + new MapComponentDataToComponentDto().doMapping(component, target); + } } - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentRequestDtoToComponentEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentRequestDtoToComponentEntity.java index 53a4482820..a890d0d737 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentRequestDtoToComponentEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentRequestDtoToComponentEntity.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; @@ -21,14 +20,14 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto; -public class MapComponentRequestDtoToComponentEntity - extends MappingBase<ComponentRequestDto, ComponentEntity> { - @Override - public void doMapping(ComponentRequestDto source, ComponentEntity target) { - ComponentData component = new ComponentData(); - component.setName(source.getName()); - component.setDisplayName(source.getDisplayName()); - component.setDescription(source.getDescription()); - target.setComponentCompositionData(component); - } +public class MapComponentRequestDtoToComponentEntity extends MappingBase<ComponentRequestDto, ComponentEntity> { + + @Override + public void doMapping(ComponentRequestDto source, ComponentEntity target) { + ComponentData component = new ComponentData(); + component.setName(source.getName()); + component.setDisplayName(source.getDisplayName()); + component.setDescription(source.getDescription()); + target.setComponentCompositionData(component); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDto.java index f7ecc243f1..743723771d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; @@ -26,22 +25,21 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionDataEntityDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; -public class MapCompositionEntityResponseToDto<S extends CompositionDataEntity, T extends - CompositionDataEntityDto, M extends MappingBase<S, T>> - extends MappingBase<CompositionEntityResponse<S>, CompositionEntityResponseDto<T>> { - private M dataMapper; - private Class<T> targetDataClass; +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; - public MapCompositionEntityResponseToDto(M dataMapper, Class<T> targetDataClass) { - this.dataMapper = dataMapper; - this.targetDataClass = targetDataClass; - } + public MapCompositionEntityResponseToDto(M dataMapper, Class<T> targetDataClass) { + this.dataMapper = dataMapper; + this.targetDataClass = targetDataClass; + } - @Override - public void doMapping(CompositionEntityResponse<S> source, - CompositionEntityResponseDto<T> target) { - target.setId(source.getId()); - target.setSchema(source.getSchema()); - target.setData(dataMapper.applyMapping(source.getData(), targetDataClass)); - } + @Override + public void doMapping(CompositionEntityResponse<S> source, CompositionEntityResponseDto<T> target) { + target.setId(source.getId()); + target.setSchema(source.getSchema()); + target.setData(dataMapper.applyMapping(source.getData(), targetDataClass)); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDto.java index ee7a9f446e..00c5c2f266 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,29 +17,26 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; +import java.util.stream.Collectors; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; -import java.util.stream.Collectors; +public class MapCompositionEntityValidationDataToDto extends MappingBase<CompositionEntityValidationData, CompositionEntityValidationDataDto> { -public class MapCompositionEntityValidationDataToDto - extends MappingBase<CompositionEntityValidationData, CompositionEntityValidationDataDto> { - @Override - public void doMapping(CompositionEntityValidationData source, - CompositionEntityValidationDataDto target) { - target.setEntityType(source.getEntityType()); - target.setEntityId(source.getEntityId()); - target.setEntityName(source.getEntityName()); - target.setErrors(source.getErrors()); - if (CollectionUtils.isNotEmpty(source.getSubEntitiesValidationData())) { - target.setSubEntitiesValidationData(source.getSubEntitiesValidationData().stream() - .map(sub -> applyMapping(sub, CompositionEntityValidationDataDto.class)) - .collect(Collectors.toList())); + @Override + public void doMapping(CompositionEntityValidationData source, CompositionEntityValidationDataDto target) { + target.setEntityType(source.getEntityType()); + target.setEntityId(source.getEntityId()); + target.setEntityName(source.getEntityName()); + target.setErrors(source.getErrors()); + if (CollectionUtils.isNotEmpty(source.getSubEntitiesValidationData())) { + target.setSubEntitiesValidationData( + source.getSubEntitiesValidationData().stream().map(sub -> applyMapping(sub, CompositionEntityValidationDataDto.class)) + .collect(Collectors.toList())); + } } - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDataToComputeDetailsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDataToComputeDetailsDto.java index 3bfecb93f5..a32f4fb076 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDataToComputeDetailsDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDataToComputeDetailsDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData; @@ -26,10 +25,9 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDetailsDto; public class MapComputeDataToComputeDetailsDto extends MappingBase<ComputeData, ComputeDetailsDto> { - @Override - public void doMapping(ComputeData source, ComputeDetailsDto target) { - - target.setName(source.getName()); - target.setDescription(source.getDescription()); - } + @Override + public void doMapping(ComputeData source, ComputeDetailsDto target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDetailsDtoToComputeEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDetailsDtoToComputeEntity.java index 93db7e3e76..835f5dd05d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDetailsDtoToComputeEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeDetailsDtoToComputeEntity.java @@ -21,13 +21,11 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDescription; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDetailsDto; -public class MapComputeDetailsDtoToComputeEntity extends MappingBase<ComputeDetailsDto, - ComputeEntity> { +public class MapComputeDetailsDtoToComputeEntity extends MappingBase<ComputeDetailsDto, ComputeEntity> { - @Override - public void doMapping(ComputeDetailsDto source, ComputeEntity target) { - ComputeDescription computeDesc = new ComputeDescription(source.getName(), source - .getDescription()); - target.setCompositionData(JsonUtil.object2Json(computeDesc)); - } + @Override + public void doMapping(ComputeDetailsDto source, ComputeEntity target) { + ComputeDescription computeDesc = new ComputeDescription(source.getName(), source.getDescription()); + target.setCompositionData(JsonUtil.object2Json(computeDesc)); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToComputeCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToComputeCreationDto.java index 4e1599d058..531c28b48a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToComputeCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToComputeCreationDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,17 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeCreationDto; -public class MapComputeEntityToComputeCreationDto extends - MappingBase<ComputeEntity, ComputeCreationDto> { - @Override - public void doMapping(ComputeEntity source, ComputeCreationDto target) { - target.setId(source.getId()); - } +public class MapComputeEntityToComputeCreationDto extends MappingBase<ComputeEntity, ComputeCreationDto> { + + @Override + public void doMapping(ComputeEntity source, ComputeCreationDto target) { + target.setId(source.getId()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToComputeDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToComputeDto.java index cd67d2444b..a2cdceb060 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToComputeDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToComputeDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.core.utilities.json.JsonUtil; @@ -27,15 +26,15 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDescription; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDto; public class MapComputeEntityToComputeDto extends MappingBase<ListComputeResponse, ComputeDto> { - @Override - public void doMapping(ListComputeResponse source, ComputeDto target) { - target.setId(source.getComputeEntity().getId()); - if (source.getComputeEntity().getCompositionData() != null) { - ComputeDescription desc = JsonUtil.json2Object(source.getComputeEntity().getCompositionData - (), ComputeDescription.class); - target.setName(desc.getName()); - target.setDescription(desc.getDescription()); - target.setAssociatedToDeploymentFlavor(source.isAssociatedWithDeploymentFlavor()); + + @Override + public void doMapping(ListComputeResponse source, ComputeDto target) { + target.setId(source.getComputeEntity().getId()); + if (source.getComputeEntity().getCompositionData() != null) { + ComputeDescription desc = JsonUtil.json2Object(source.getComputeEntity().getCompositionData(), ComputeDescription.class); + target.setName(desc.getName()); + target.setDescription(desc.getDescription()); + target.setAssociatedToDeploymentFlavor(source.isAssociatedWithDeploymentFlavor()); + } } - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToVspComputeDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToVspComputeDto.java index c75266f756..108d6438b5 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToVspComputeDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComputeEntityToVspComputeDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.core.utilities.json.JsonUtil; @@ -27,14 +26,14 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDescription; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto; public class MapComputeEntityToVspComputeDto extends MappingBase<ComputeEntity, VspComputeDto> { - @Override - public void doMapping(ComputeEntity source, VspComputeDto target) { - target.setComputeFlavorId(source.getId()); - if (source.getCompositionData() != null) { - ComputeDescription desc = JsonUtil.json2Object(source.getCompositionData(), ComputeDescription - .class); - target.setName(desc.getName()); - target.setComponentId(source.getComponentId()); + + @Override + public void doMapping(ComputeEntity source, VspComputeDto target) { + target.setComputeFlavorId(source.getId()); + if (source.getCompositionData() != null) { + ComputeDescription desc = JsonUtil.json2Object(source.getCompositionData(), ComputeDescription.class); + target.setName(desc.getName()); + target.setComponentId(source.getComponentId()); + } } - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityDeploymentFlavorToListResponse.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityDeploymentFlavorToListResponse.java index 42ff7c9058..292ee88ef9 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityDeploymentFlavorToListResponse.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityDeploymentFlavorToListResponse.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; @@ -25,18 +24,15 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavo import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorListResponseDto; -public class MapDeploymentFlavorEntityDeploymentFlavorToListResponse extends - MappingBase<DeploymentFlavorEntity, DeploymentFlavorListResponseDto> { - - @Override - public void doMapping(DeploymentFlavorEntity source, - DeploymentFlavorListResponseDto target) { - target.setId(source.getId()); - DeploymentFlavor deploymentFlavor = source.getDeploymentFlavorCompositionData(); +public class MapDeploymentFlavorEntityDeploymentFlavorToListResponse extends MappingBase<DeploymentFlavorEntity, DeploymentFlavorListResponseDto> { - if (deploymentFlavor != null) { - target.setModel(deploymentFlavor.getModel()); - target.setDescription(deploymentFlavor.getDescription()); + @Override + public void doMapping(DeploymentFlavorEntity source, DeploymentFlavorListResponseDto target) { + target.setId(source.getId()); + DeploymentFlavor deploymentFlavor = source.getDeploymentFlavorCompositionData(); + if (deploymentFlavor != null) { + target.setModel(deploymentFlavor.getModel()); + target.setDescription(deploymentFlavor.getDescription()); + } } - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorCreationDto.java index 05fa35d0ba..80b6649005 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorCreationDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,20 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorCreationDto; +public class MapDeploymentFlavorEntityToDeploymentFlavorCreationDto extends MappingBase<DeploymentFlavorEntity, DeploymentFlavorCreationDto> { -public class MapDeploymentFlavorEntityToDeploymentFlavorCreationDto extends MappingBase<DeploymentFlavorEntity, - DeploymentFlavorCreationDto> { - - @Override - public void doMapping(DeploymentFlavorEntity source, - DeploymentFlavorCreationDto target) { - target.setDeploymentFlavorId(source.getId()); - } + @Override + public void doMapping(DeploymentFlavorEntity source, DeploymentFlavorCreationDto target) { + target.setDeploymentFlavorId(source.getId()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorDto.java index 188ff82636..dbf9b2adf9 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorEntityToDeploymentFlavorDto.java @@ -13,19 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.mapping; - import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; -public class MapDeploymentFlavorEntityToDeploymentFlavorDto extends - MappingBase<DeploymentFlavorEntity, DeploymentFlavorDto> { - @Override - public void doMapping(DeploymentFlavorEntity source, DeploymentFlavorDto target) { - target.setId(source.getId()); +public class MapDeploymentFlavorEntityToDeploymentFlavorDto extends MappingBase<DeploymentFlavorEntity, DeploymentFlavorDto> { - } + @Override + public void doMapping(DeploymentFlavorEntity source, DeploymentFlavorDto target) { + target.setId(source.getId()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity.java index 97ccf28def..6bd60b81a2 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; @@ -25,16 +24,15 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavo import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorRequestDto; -public class MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity - extends MappingBase<DeploymentFlavorRequestDto, DeploymentFlavorEntity> { +public class MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity extends MappingBase<DeploymentFlavorRequestDto, DeploymentFlavorEntity> { - @Override - public void doMapping(DeploymentFlavorRequestDto source, DeploymentFlavorEntity target) { - DeploymentFlavor deploymentFlavor = new DeploymentFlavor(); - deploymentFlavor.setModel(source.getModel()); - deploymentFlavor.setDescription(source.getDescription()); - deploymentFlavor.setFeatureGroupId(source.getFeatureGroupId()); - deploymentFlavor.setComponentComputeAssociations(source.getComponentComputeAssociations()); - target.setDeploymentFlavorCompositionData(deploymentFlavor); - } + @Override + public void doMapping(DeploymentFlavorRequestDto source, DeploymentFlavorEntity target) { + DeploymentFlavor deploymentFlavor = new DeploymentFlavor(); + deploymentFlavor.setModel(source.getModel()); + deploymentFlavor.setDescription(source.getDescription()); + deploymentFlavor.setFeatureGroupId(source.getFeatureGroupId()); + deploymentFlavor.setComponentComputeAssociations(source.getComponentComputeAssociations()); + target.setDeploymentFlavorCompositionData(deploymentFlavor); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorToDeploymentDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorToDeploymentDto.java index 06d299c805..b26669e511 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorToDeploymentDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapDeploymentFlavorToDeploymentDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,20 +17,19 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; - public class MapDeploymentFlavorToDeploymentDto extends MappingBase<DeploymentFlavor, DeploymentFlavorDto> { - @Override - public void doMapping(DeploymentFlavor source, DeploymentFlavorDto target) { - target.setModel(source.getModel()); - target.setDescription(source.getDescription()); - target.setFeatureGroupId(source.getFeatureGroupId()); - target.setComponentComputeAssociations(source.getComponentComputeAssociations()); - } + + @Override + public void doMapping(DeploymentFlavor source, DeploymentFlavorDto target) { + target.setModel(source.getModel()); + target.setDescription(source.getDescription()); + target.setFeatureGroupId(source.getFeatureGroupId()); + target.setComponentComputeAssociations(source.getComponentComputeAssociations()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToDto.java index c8734ff8ee..a769a4ed1b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,21 +17,19 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.FileDataStructureDto; -public class MapFilesDataStructureToDto - extends MappingBase<FilesDataStructure, FileDataStructureDto> { +public class MapFilesDataStructureToDto extends MappingBase<FilesDataStructure, FileDataStructureDto> { - @Override - public void doMapping(FilesDataStructure source, FileDataStructureDto target) { - target.setModules(source.getModules()); - target.setArtifacts(source.getArtifacts()); - target.setNested(source.getNested()); - target.setUnassigned(source.getUnassigned()); - } + @Override + public void doMapping(FilesDataStructure source, FileDataStructureDto target) { + target.setModules(source.getModules()); + target.setArtifacts(source.getArtifacts()); + target.setNested(source.getNested()); + target.setUnassigned(source.getUnassigned()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageDataToImageDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageDataToImageDto.java index 4df6eb3de9..005de5fe9c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageDataToImageDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageDataToImageDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,25 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ImageData; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto; - public class MapImageDataToImageDto extends MappingBase<ImageData, ImageDto> { - @Override - public void doMapping(ImageData source, ImageDto target) { - target.setFileName(source.getFileName()); - target.setDescription(source.getDescription()); - } + @Override + public void doMapping(ImageData source, ImageDto target) { + target.setFileName(source.getFileName()); + target.setDescription(source.getDescription()); + } } - - - - - - diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageEntityToImageCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageEntityToImageCreationDto.java index cc15ef0898..5a811b2228 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageEntityToImageCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageEntityToImageCreationDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,18 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageCreationDto; -public class MapImageEntityToImageCreationDto extends MappingBase<ImageEntity, - ImageCreationDto> { +public class MapImageEntityToImageCreationDto extends MappingBase<ImageEntity, ImageCreationDto> { - @Override - public void doMapping(ImageEntity source, ImageCreationDto target) { - target.setId(source.getId()); - } + @Override + public void doMapping(ImageEntity source, ImageCreationDto target) { + target.setId(source.getId()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageEntityToImageDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageEntityToImageDto.java index b35a0f2a38..d17735483f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageEntityToImageDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageEntityToImageDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; @@ -27,14 +26,14 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto; public class MapImageEntityToImageDto extends MappingBase<ImageEntity, ImageDto> { - @Override - public void doMapping(ImageEntity source, ImageDto target) { - target.setId(source.getId()); - Image image = source.getImageCompositionData(); - if (image != null) { - ImageData imageData = new ImageData(image.getFileName(), image.getDescription()); - new MapImageDataToImageDto().doMapping(imageData, target); + @Override + public void doMapping(ImageEntity source, ImageDto target) { + target.setId(source.getId()); + Image image = source.getImageCompositionData(); + if (image != null) { + ImageData imageData = new ImageData(image.getFileName(), image.getDescription()); + new MapImageDataToImageDto().doMapping(imageData, target); + } } - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageRequestDtoToImageEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageRequestDtoToImageEntity.java index 3e1c126226..fa2f432e89 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageRequestDtoToImageEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapImageRequestDtoToImageEntity.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; @@ -23,12 +22,11 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageRequestDto; public class MapImageRequestDtoToImageEntity extends MappingBase<ImageRequestDto, ImageEntity> { - @Override - public void doMapping(ImageRequestDto source, ImageEntity target) { - Image image = new Image(); - image.setFileName(source.getFileName()); - image.setDescription(source.getDescription()); - target.setImageCompositionData(image); - } - + @Override + public void doMapping(ImageRequestDto source, ImageEntity target) { + Image image = new Image(); + image.setFileName(source.getFileName()); + image.setDescription(source.getDescription()); + target.setImageCompositionData(image); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapItemToVspDetailsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapItemToVspDetailsDto.java index 926f1f0b25..e0966e8350 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapItemToVspDetailsDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapItemToVspDetailsDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.versioning.types.Item; @@ -26,15 +25,16 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; import org.openecomp.sdcrests.vsp.rest.services.VspItemProperty; public class MapItemToVspDetailsDto extends MappingBase<Item, VspDetailsDto> { - @Override - public void doMapping(Item source, VspDetailsDto target) { - target.setId(source.getId()); - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setVendorId((String) source.getProperties().get(VspItemProperty.VENDOR_ID)); - target.setVendorName((String) source.getProperties().get(VspItemProperty.VENDOR_NAME)); - target.setOnboardingMethod((String) source.getProperties().get(VspItemProperty.ONBOARDING_METHOD)); - target.setOwner(source.getOwner()); - target.setStatus(source.getStatus().name()); - } + + @Override + public void doMapping(Item source, VspDetailsDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setVendorId((String) source.getProperties().get(VspItemProperty.VENDOR_ID)); + target.setVendorName((String) source.getProperties().get(VspItemProperty.VENDOR_NAME)); + target.setOnboardingMethod((String) source.getProperties().get(VspItemProperty.ONBOARDING_METHOD)); + target.setOwner(source.getOwner()); + target.setStatus(source.getStatus().name()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapMonitoringUploadStatusToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapMonitoringUploadStatusToDto.java index 08d322dad0..08add59679 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapMonitoringUploadStatusToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapMonitoringUploadStatusToDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,19 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringUploadStatus; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.MonitoringUploadStatusDto; -public class MapMonitoringUploadStatusToDto - extends MappingBase<MonitoringUploadStatus, MonitoringUploadStatusDto> { - @Override - public void doMapping(MonitoringUploadStatus source, MonitoringUploadStatusDto target) { - target.setSnmpPoll(source.getSnmpPoll()); - target.setSnmpTrap(source.getSnmpTrap()); - target.setVesEvent(source.getVesEvent()); - } +public class MapMonitoringUploadStatusToDto extends MappingBase<MonitoringUploadStatus, MonitoringUploadStatusDto> { + + @Override + public void doMapping(MonitoringUploadStatus source, MonitoringUploadStatusDto target) { + target.setSnmpPoll(source.getSnmpPoll()); + target.setSnmpTrap(source.getSnmpTrap()); + target.setVesEvent(source.getVesEvent()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkEntityToNetworkDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkEntityToNetworkDto.java index 1d79f35769..cf2ced753e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkEntityToNetworkDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkEntityToNetworkDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; @@ -26,12 +25,13 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; public class MapNetworkEntityToNetworkDto extends MappingBase<NetworkEntity, NetworkDto> { - @Override - public void doMapping(NetworkEntity source, NetworkDto target) { - target.setId(source.getId()); - Network network = source.getNetworkCompositionData(); - if (network != null) { - new MapNetworkToNetworkDto().doMapping(network, target); + + @Override + public void doMapping(NetworkEntity source, NetworkDto target) { + target.setId(source.getId()); + Network network = source.getNetworkCompositionData(); + if (network != null) { + new MapNetworkToNetworkDto().doMapping(network, target); + } } - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkRequestDtoToNetworkEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkRequestDtoToNetworkEntity.java index 00395c4b99..4db9209c53 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkRequestDtoToNetworkEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkRequestDtoToNetworkEntity.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; @@ -25,13 +24,13 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkRequestDto; -public class MapNetworkRequestDtoToNetworkEntity - extends MappingBase<NetworkRequestDto, NetworkEntity> { - @Override - public void doMapping(NetworkRequestDto source, NetworkEntity target) { - Network network = new Network(); - network.setName(source.getName()); - network.setDhcp(source.isDhcp()); - target.setNetworkCompositionData(network); - } +public class MapNetworkRequestDtoToNetworkEntity extends MappingBase<NetworkRequestDto, NetworkEntity> { + + @Override + public void doMapping(NetworkRequestDto source, NetworkEntity target) { + Network network = new Network(); + network.setName(source.getName()); + network.setDhcp(source.isDhcp()); + target.setNetworkCompositionData(network); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkToNetworkDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkToNetworkDto.java index dd819de1a6..6cede067f1 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkToNetworkDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNetworkToNetworkDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; @@ -25,9 +24,10 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; public class MapNetworkToNetworkDto extends MappingBase<Network, NetworkDto> { - @Override - public void doMapping(Network source, NetworkDto target) { - target.setName(source.getName()); - target.setDhcp(source.isDhcp()); - } + + @Override + public void doMapping(Network source, NetworkDto target) { + target.setName(source.getName()); + target.setDhcp(source.isDhcp()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicEntityToNicCreationResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicEntityToNicCreationResponseDto.java index 835ff0b7b9..a3be49e684 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicEntityToNicCreationResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicEntityToNicCreationResponseDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,20 +17,16 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; - import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicCreationResponseDto; -public class MapNicEntityToNicCreationResponseDto extends MappingBase<NicEntity, - NicCreationResponseDto> { - +public class MapNicEntityToNicCreationResponseDto extends MappingBase<NicEntity, NicCreationResponseDto> { - @Override - public void doMapping(NicEntity source, NicCreationResponseDto target) { - target.setNicId(source.getId()); - } + @Override + public void doMapping(NicEntity source, NicCreationResponseDto target) { + target.setNicId(source.getId()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicEntityToNicDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicEntityToNicDto.java index 2af7e2ff6b..ea56e73237 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicEntityToNicDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicEntityToNicDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; @@ -26,12 +25,13 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; public class MapNicEntityToNicDto extends MappingBase<NicEntity, NicDto> { - @Override - public void doMapping(NicEntity source, NicDto target) { - target.setId(source.getId()); - Nic nic = source.getNicCompositionData(); - if (nic != null) { - new MapNicToNicDto().doMapping(nic, target); + + @Override + public void doMapping(NicEntity source, NicDto target) { + target.setId(source.getId()); + Nic nic = source.getNicCompositionData(); + if (nic != null) { + new MapNicToNicDto().doMapping(nic, target); + } } - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicRequestDtoToNicEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicRequestDtoToNicEntity.java index 7fd0253556..da2d7c8814 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicRequestDtoToNicEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicRequestDtoToNicEntity.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; @@ -27,14 +26,15 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicRequestDto; public class MapNicRequestDtoToNicEntity extends MappingBase<NicRequestDto, NicEntity> { - @Override - public void doMapping(NicRequestDto source, NicEntity target) { - Nic nic = new Nic(); - nic.setName(source.getName()); - nic.setDescription(source.getDescription()); - nic.setNetworkId(source.getNetworkId()); - nic.setNetworkType(NetworkType.valueOf(source.getNetworkType())); - nic.setNetworkDescription(source.getNetworkDescription()); - target.setNicCompositionData(nic); - } + + @Override + public void doMapping(NicRequestDto source, NicEntity target) { + Nic nic = new Nic(); + nic.setName(source.getName()); + nic.setDescription(source.getDescription()); + nic.setNetworkId(source.getNetworkId()); + nic.setNetworkType(NetworkType.valueOf(source.getNetworkType())); + nic.setNetworkDescription(source.getNetworkDescription()); + target.setNicCompositionData(nic); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicToNicDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicToNicDto.java index 8c48f18b3d..4a22fb5f19 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicToNicDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapNicToNicDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; @@ -25,15 +24,16 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; public class MapNicToNicDto extends MappingBase<Nic, NicDto> { - @Override - public void doMapping(Nic source, NicDto target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setNetworkId(source.getNetworkId()); - target.setNetworkName(source.getNetworkName()); - if (source.getNetworkType() != null) { - target.setNetworkType(source.getNetworkType().name()); + + @Override + public void doMapping(Nic source, NicDto target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setNetworkId(source.getNetworkId()); + target.setNetworkName(source.getNetworkName()); + if (source.getNetworkType() != null) { + target.setNetworkType(source.getNetworkType().name()); + } + target.setNetworkDescription(source.getNetworkDescription()); } - target.setNetworkDescription(source.getNetworkDescription()); - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java index 1bf13f8c3f..c6faa0361b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; @@ -28,18 +27,19 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; * Created by TALIO on 4/25/2016. */ public class MapPackageInfoToPackageInfoDto extends MappingBase<PackageInfo, PackageInfoDto> { - @Override - public void doMapping(PackageInfo source, PackageInfoDto target) { - target.setVspName(source.getVspName()); - target.setPackageId(source.getVspId()); - target.setDescription(source.getVspDescription()); - target.setVersion(source.getVersion()); - target.setPackageType(source.getPackageType()); - target.setCategory(source.getCategory()); - target.setSubCategory(source.getSubCategory()); - target.setPackageChecksum(source.getPackageChecksum()); - target.setVendorRelease(source.getVendorRelease()); - target.setVendorName(source.getVendorName()); - target.setResourceType(source.getResourceType()); - } + + @Override + public void doMapping(PackageInfo source, PackageInfoDto target) { + target.setVspName(source.getVspName()); + target.setPackageId(source.getVspId()); + target.setDescription(source.getVspDescription()); + target.setVersion(source.getVersion()); + target.setPackageType(source.getPackageType()); + target.setCategory(source.getCategory()); + target.setSubCategory(source.getSubCategory()); + target.setPackageChecksum(source.getPackageChecksum()); + target.setVendorRelease(source.getVendorRelease()); + target.setVendorName(source.getVendorName()); + target.setResourceType(source.getResourceType()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessEntityToProcessEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessEntityToProcessEntityDto.java index 96a67a9d87..6d6a6d29de 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessEntityToProcessEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessEntityToProcessEntityDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,21 +17,20 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto; -public class MapProcessEntityToProcessEntityDto - extends MappingBase<ProcessEntity, ProcessEntityDto> { - @Override - public void doMapping(ProcessEntity source, ProcessEntityDto target) { - target.setId(source.getId()); - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setType(source.getType()); - target.setArtifactName(source.getArtifactName()); - } +public class MapProcessEntityToProcessEntityDto extends MappingBase<ProcessEntity, ProcessEntityDto> { + + @Override + public void doMapping(ProcessEntity source, ProcessEntityDto target) { + target.setId(source.getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setType(source.getType()); + target.setArtifactName(source.getArtifactName()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessRequestDtoToProcessEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessRequestDtoToProcessEntity.java index d1a28d7145..2f53b24d25 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessRequestDtoToProcessEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessRequestDtoToProcessEntity.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,19 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; -public class MapProcessRequestDtoToProcessEntity - extends MappingBase<ProcessRequestDto, ProcessEntity> { - @Override - public void doMapping(ProcessRequestDto source, ProcessEntity target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setType(source.getType()); - } +public class MapProcessRequestDtoToProcessEntity extends MappingBase<ProcessRequestDto, ProcessEntity> { + + @Override + public void doMapping(ProcessRequestDto source, ProcessEntity target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setType(source.getType()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireResponseToQuestionnaireResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireResponseToQuestionnaireResponseDto.java index 52252c0425..598596b030 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireResponseToQuestionnaireResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireResponseToQuestionnaireResponseDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,20 +17,18 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; -public class MapQuestionnaireResponseToQuestionnaireResponseDto - extends MappingBase<QuestionnaireResponse, QuestionnaireResponseDto> { +public class MapQuestionnaireResponseToQuestionnaireResponseDto extends MappingBase<QuestionnaireResponse, QuestionnaireResponseDto> { - @Override - public void doMapping(QuestionnaireResponse source, QuestionnaireResponseDto target) { - target.setData(source.getData()); - target.setSchema(source.getSchema()); - target.setErrorMessage(source.getErrorMessage()); - } + @Override + public void doMapping(QuestionnaireResponse source, QuestionnaireResponseDto target) { + target.setData(source.getData()); + target.setSchema(source.getSchema()); + target.setErrorMessage(source.getErrorMessage()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireToQuestionnaireDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireToQuestionnaireDto.java index fe8e3c5ea4..e846f0e047 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireToQuestionnaireDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireToQuestionnaireDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,25 +17,22 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; +import java.util.HashMap; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireDto; -import java.util.HashMap; - /** * Created by ayalaben on 9/26/2017 */ -public class MapQuestionnaireToQuestionnaireDto extends - MappingBase<CompositionEntity, QuestionnaireDto> { +public class MapQuestionnaireToQuestionnaireDto extends MappingBase<CompositionEntity, QuestionnaireDto> { - @Override - public void doMapping(CompositionEntity source, QuestionnaireDto target) { - target.setId(source.getId()); - target.setQuestionareData(JsonUtil.json2Object(source.getQuestionnaireData(), HashMap.class)); - } + @Override + public void doMapping(CompositionEntity source, QuestionnaireDto target) { + target.setId(source.getId()); + target.setQuestionareData(JsonUtil.json2Object(source.getQuestionnaireData(), HashMap.class)); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapUploadFileResponseToUploadFileResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapUploadFileResponseToUploadFileResponseDto.java index 48053d053d..f78e2e0dee 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapUploadFileResponseToUploadFileResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapUploadFileResponseToUploadFileResponseDto.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,10 +17,8 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; - import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; @@ -28,13 +26,13 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto /** * Created by TALIO on 4/27/2016. */ -public class MapUploadFileResponseToUploadFileResponseDto - extends MappingBase<UploadFileResponse, UploadFileResponseDto> { - @Override - public void doMapping(UploadFileResponse source, UploadFileResponseDto target) { - target.setStatus(source.getStatus()); - target.setErrors(source.getErrors()); - target.setOnboardingOrigin(source.getOnboardingType().toString()); - target.setNetworkPackageName(source.getNetworkPackageName()); - } +public class MapUploadFileResponseToUploadFileResponseDto extends MappingBase<UploadFileResponse, UploadFileResponseDto> { + + @Override + public void doMapping(UploadFileResponse source, UploadFileResponseDto target) { + target.setStatus(source.getStatus()); + target.setErrors(source.getErrors()); + target.setOnboardingOrigin(source.getOnboardingType().toString()); + target.setNetworkPackageName(source.getNetworkPackageName()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java index b3fbe1e7c9..8048786f69 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java @@ -13,9 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.mapping; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.openecomp.sdc.common.errors.ErrorCode; @@ -32,61 +38,47 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityVali import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireValidationResultDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto; -import java.util.*; -import java.util.stream.Collectors; +public class MapValidationResponseToDto extends MappingBase<ValidationResponse, ValidationResponseDto> { -public class MapValidationResponseToDto - extends MappingBase<ValidationResponse, ValidationResponseDto> { - private static Map<String, List<ErrorMessageDto>> mapUploadDataErrors( - Map<String, List<ErrorMessage>> uploadDataErrors) { - if (MapUtils.isEmpty(uploadDataErrors)) { - return null; + private static Map<String, List<ErrorMessageDto>> mapUploadDataErrors(Map<String, List<ErrorMessage>> uploadDataErrors) { + if (MapUtils.isEmpty(uploadDataErrors)) { + return null; + } + return uploadDataErrors.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> mapErrorMessages(entry.getValue()))); } - return uploadDataErrors.entrySet().stream().collect( - Collectors.toMap(Map.Entry::getKey, entry -> mapErrorMessages(entry.getValue()))); - } - private static QuestionnaireValidationResultDto mapQuestionnaireValidationResult( - QuestionnaireValidationResult questionnaireValidationResult) { - if (Objects.isNull(questionnaireValidationResult) - || Objects.isNull(questionnaireValidationResult.getValidationData())) { - return null; + private static QuestionnaireValidationResultDto mapQuestionnaireValidationResult(QuestionnaireValidationResult questionnaireValidationResult) { + if (Objects.isNull(questionnaireValidationResult) || Objects.isNull(questionnaireValidationResult.getValidationData())) { + return null; + } + QuestionnaireValidationResultDto questionnaireValidationResultDto = new QuestionnaireValidationResultDto(); + questionnaireValidationResultDto.setValid(questionnaireValidationResult.isValid()); + Set<CompositionEntityValidationDataDto> validationDataDto = new HashSet<>(); + for (CompositionEntityValidationData validationData : questionnaireValidationResult.getValidationData()) { + validationDataDto + .add(new MapCompositionEntityValidationDataToDto().applyMapping(validationData, CompositionEntityValidationDataDto.class)); + } + questionnaireValidationResultDto.setValidationData(validationDataDto); + return questionnaireValidationResultDto; } - QuestionnaireValidationResultDto questionnaireValidationResultDto = - new QuestionnaireValidationResultDto(); - questionnaireValidationResultDto.setValid(questionnaireValidationResult.isValid()); - Set<CompositionEntityValidationDataDto> validationDataDto = new HashSet<>(); - for (CompositionEntityValidationData validationData : questionnaireValidationResult - .getValidationData()) { - validationDataDto.add(new MapCompositionEntityValidationDataToDto().applyMapping( - validationData, CompositionEntityValidationDataDto.class)); + private static List<ErrorMessageDto> mapErrorMessages(List<ErrorMessage> errorMessages) { + return errorMessages == null ? null + : errorMessages.stream().map(errorMessage -> new MapErrorMessageToDto().applyMapping(errorMessage, ErrorMessageDto.class)) + .collect(Collectors.toList()); } - questionnaireValidationResultDto.setValidationData(validationDataDto); - return questionnaireValidationResultDto; - } - - - private static List<ErrorMessageDto> mapErrorMessages(List<ErrorMessage> errorMessages) { - return errorMessages == null ? null : errorMessages.stream().map( - errorMessage -> new MapErrorMessageToDto() - .applyMapping(errorMessage, ErrorMessageDto.class)).collect(Collectors.toList()); - } - - private static Collection<ErrorCodeDto> mapErrorCodes(Collection<ErrorCode> errorCodes) { - return CollectionUtils.isEmpty(errorCodes) ? null : errorCodes.stream() - .map(errorCode -> new MapErrorCodeToDto().applyMapping(errorCode, ErrorCodeDto.class)) - .collect(Collectors.toList()); - } + private static Collection<ErrorCodeDto> mapErrorCodes(Collection<ErrorCode> errorCodes) { + return CollectionUtils.isEmpty(errorCodes) ? null + : errorCodes.stream().map(errorCode -> new MapErrorCodeToDto().applyMapping(errorCode, ErrorCodeDto.class)).collect(Collectors.toList()); + } - @Override - public void doMapping(ValidationResponse source, ValidationResponseDto target) { - target.setValid(source.isValid()); - target.setVspErrors(mapErrorCodes(source.getVspErrors())); - target.setLicensingDataErrors(mapErrorCodes(source.getLicensingDataErrors())); - target.setUploadDataErrors(mapUploadDataErrors(source.getUploadDataErrors())); - target.setQuestionnaireValidationResult( - mapQuestionnaireValidationResult(source.getQuestionnaireValidationResult())); - } + @Override + public void doMapping(ValidationResponse source, ValidationResponseDto target) { + target.setValid(source.isValid()); + target.setVspErrors(mapErrorCodes(source.getVspErrors())); + target.setLicensingDataErrors(mapErrorCodes(source.getLicensingDataErrors())); + target.setUploadDataErrors(mapUploadDataErrors(source.getUploadDataErrors())); + target.setQuestionnaireValidationResult(mapQuestionnaireValidationResult(source.getQuestionnaireValidationResult())); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToItem.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToItem.java index 484b7c80bb..0543c20298 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToItem.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToItem.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.versioning.types.Item; @@ -26,11 +25,12 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; import org.openecomp.sdcrests.vsp.rest.services.VspItemProperty; public class MapVspDescriptionDtoToItem extends MappingBase<VspDescriptionDto, Item> { - @Override - public void doMapping(VspDescriptionDto source, Item target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.addProperty(VspItemProperty.VENDOR_ID, source.getVendorId()); - target.addProperty(VspItemProperty.VENDOR_NAME, source.getVendorName()); - } + + @Override + public void doMapping(VspDescriptionDto source, Item target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.addProperty(VspItemProperty.VENDOR_ID, source.getVendorId()); + target.addProperty(VspItemProperty.VENDOR_NAME, source.getVendorName()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java index 3ab2667821..4c9c16df89 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.LicenseType; @@ -29,27 +28,25 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; public class MapVspDescriptionDtoToVspDetails extends MappingBase<VspDescriptionDto, VspDetails> { - @Override - public void doMapping(VspDescriptionDto source, VspDetails target) { - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setCategory(source.getCategory()); - target.setSubCategory(source.getSubCategory()); - target.setIcon(source.getIcon()); - target.setVendorName(source.getVendorName()); - target.setVendorId(source.getVendorId()); - - if (source.getLicensingVersion() != null && source.getLicenseType() != LicenseType.EXTERNAL) { - target.setVlmVersion(new Version(source.getLicensingVersion())); - } - if (source.getLicenseType() != null) { - target.setLicenseType(source.getLicenseType().name()); - } - - LicensingData licensingData = source.getLicensingData(); - if (licensingData != null && source.getLicenseType() != LicenseType.EXTERNAL) { - target.setLicenseAgreement(licensingData.getLicenseAgreement()); - target.setFeatureGroups(licensingData.getFeatureGroups()); + @Override + public void doMapping(VspDescriptionDto source, VspDetails target) { + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setCategory(source.getCategory()); + target.setSubCategory(source.getSubCategory()); + target.setIcon(source.getIcon()); + target.setVendorName(source.getVendorName()); + target.setVendorId(source.getVendorId()); + if (source.getLicensingVersion() != null && source.getLicenseType() != LicenseType.EXTERNAL) { + target.setVlmVersion(new Version(source.getLicensingVersion())); + } + if (source.getLicenseType() != null) { + target.setLicenseType(source.getLicenseType().name()); + } + LicensingData licensingData = source.getLicensingData(); + if (licensingData != null && source.getLicenseType() != LicenseType.EXTERNAL) { + target.setLicenseAgreement(licensingData.getLicenseAgreement()); + target.setFeatureGroups(licensingData.getFeatureGroups()); + } } - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToDto.java index 1ba5d1355c..1605ab7218 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToDto.java @@ -17,7 +17,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.mapping; import org.apache.commons.lang3.StringUtils; @@ -29,31 +28,29 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; public class MapVspDetailsToDto extends MappingBase<VspDetails, VspDetailsDto> { - @Override - public void doMapping(VspDetails source, VspDetailsDto target) { - target.setId(source.getId()); - target.setVersion(source.getVersion() == null ? null : source.getVersion().getId()); - target.setName(source.getName()); - target.setDescription(source.getDescription()); - target.setIcon(source.getIcon()); - target.setCategory(source.getCategory()); - target.setSubCategory(source.getSubCategory()); - target.setVendorId(source.getVendorId()); - target.setVendorName(source.getVendorName()); - target.setLicensingVersion( - source.getVlmVersion() == null ? null : source.getVlmVersion().getId()); - if (StringUtils.isNotBlank(source.getLicenseType())) { - target.setLicenseType(LicenseType.valueOf(source.getLicenseType())); - } else if (StringUtils.isNotBlank(target.getLicensingVersion())){ - target.setLicenseType(LicenseType.INTERNAL); - } - if (source.getLicenseAgreement() != null || source.getFeatureGroups() != null) { - LicensingData licensingData = new LicensingData(); - licensingData.setLicenseAgreement(source.getLicenseAgreement()); - licensingData.setFeatureGroups(source.getFeatureGroups()); - target.setLicensingData(licensingData); + @Override + public void doMapping(VspDetails source, VspDetailsDto target) { + target.setId(source.getId()); + target.setVersion(source.getVersion() == null ? null : source.getVersion().getId()); + target.setName(source.getName()); + target.setDescription(source.getDescription()); + target.setIcon(source.getIcon()); + target.setCategory(source.getCategory()); + target.setSubCategory(source.getSubCategory()); + target.setVendorId(source.getVendorId()); + target.setVendorName(source.getVendorName()); + target.setLicensingVersion(source.getVlmVersion() == null ? null : source.getVlmVersion().getId()); + if (StringUtils.isNotBlank(source.getLicenseType())) { + target.setLicenseType(LicenseType.valueOf(source.getLicenseType())); + } else if (StringUtils.isNotBlank(target.getLicensingVersion())) { + target.setLicenseType(LicenseType.INTERNAL); + } + if (source.getLicenseAgreement() != null || source.getFeatureGroups() != null) { + LicensingData licensingData = new LicensingData(); + licensingData.setLicenseAgreement(source.getLicenseAgreement()); + licensingData.setFeatureGroups(source.getFeatureGroups()); + target.setLicensingData(licensingData); + } + target.setOnboardingMethod(source.getOnboardingMethod()); } - - target.setOnboardingMethod(source.getOnboardingMethod()); - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependenciesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependenciesImpl.java index becfac97b6..2357e94a95 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependenciesImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependenciesImpl.java @@ -13,9 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManager; import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; @@ -31,103 +33,73 @@ import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("componentDependencies") @Scope(value = "prototype") public class ComponentDependenciesImpl implements ComponentDependencies { - private final ComponentDependencyModelManager componentDependencyModelManager; - - public ComponentDependenciesImpl() { - this.componentDependencyModelManager = - ComponentDependencyModelManagerFactory.getInstance().createInterface(); - } - - public ComponentDependenciesImpl(ComponentDependencyModelManager componentDependencyModelManager) { - this.componentDependencyModelManager = componentDependencyModelManager; - } - - @Override - public Response create(ComponentDependencyModel request, String vspId, String versionId, - String user) { - final Version version = new Version(versionId); - - ComponentDependencyModelEntity modelEntity = - new MapComponentDependencyModelRequestToEntity().applyMapping(request, - ComponentDependencyModelEntity.class); - - modelEntity.setVspId(vspId); - modelEntity.setVersion(version); - - ComponentDependencyModelEntity componentDependency = - componentDependencyModelManager.createComponentDependency(modelEntity, vspId, version); - - MapComponentDependencyEntityToCreationDto mapping = - new MapComponentDependencyEntityToCreationDto(); - ComponentDependencyCreationDto createdComponentDependencyDto = mapping.applyMapping( - componentDependency, ComponentDependencyCreationDto.class); - return Response.ok(componentDependency != null ? createdComponentDependencyDto : null) - .build(); - } + private final ComponentDependencyModelManager componentDependencyModelManager; - @Override - public Response list(String vspId, String versionId, String user) { - - Version vspVersion = new Version(versionId); - - Collection<ComponentDependencyModelEntity> componentDependencies = - componentDependencyModelManager.list(vspId, vspVersion); - - MapComponentDependencyEntityToDto mapper = new MapComponentDependencyEntityToDto(); - GenericCollectionWrapper<ComponentDependencyResponseDto> results = new GenericCollectionWrapper - <>(); - for (ComponentDependencyModelEntity entity : componentDependencies) { - results.add(mapper.applyMapping(entity, ComponentDependencyResponseDto.class)); + public ComponentDependenciesImpl() { + this.componentDependencyModelManager = ComponentDependencyModelManagerFactory.getInstance().createInterface(); } - return Response.ok(results).build(); - } - - @Override - public Response delete(String vspId, String versionId, String dependencyId, String user) { - - Version vspVersion = new Version(versionId); - componentDependencyModelManager.delete(vspId, vspVersion, dependencyId); - return Response.ok().build(); - } - - @Override - public Response update(ComponentDependencyModel request, String vspId, String versionId, String - dependencyId, String user) { - - final Version version = new Version(versionId); - ComponentDependencyModelEntity modelEntity = - new MapComponentDependencyModelRequestToEntity().applyMapping(request, - ComponentDependencyModelEntity.class); - - modelEntity.setId(dependencyId); - modelEntity.setVspId(vspId); - modelEntity.setVersion(version); - componentDependencyModelManager.update(modelEntity); - return Response.ok().build(); - } + public ComponentDependenciesImpl(ComponentDependencyModelManager componentDependencyModelManager) { + this.componentDependencyModelManager = componentDependencyModelManager; + } - @Override - public Response get(String vspId, String version, String dependencyId, String user) { + @Override + public Response create(ComponentDependencyModel request, String vspId, String versionId, String user) { + final Version version = new Version(versionId); + ComponentDependencyModelEntity modelEntity = new MapComponentDependencyModelRequestToEntity() + .applyMapping(request, ComponentDependencyModelEntity.class); + modelEntity.setVspId(vspId); + modelEntity.setVersion(version); + ComponentDependencyModelEntity componentDependency = componentDependencyModelManager.createComponentDependency(modelEntity, vspId, version); + MapComponentDependencyEntityToCreationDto mapping = new MapComponentDependencyEntityToCreationDto(); + ComponentDependencyCreationDto createdComponentDependencyDto = mapping + .applyMapping(componentDependency, ComponentDependencyCreationDto.class); + return Response.ok(componentDependency != null ? createdComponentDependencyDto : null).build(); + } - ComponentDependencyModelEntity componentDependencyModelEntity = componentDependencyModelManager - .get(vspId, new Version(version), dependencyId); + @Override + public Response list(String vspId, String versionId, String user) { + Version vspVersion = new Version(versionId); + Collection<ComponentDependencyModelEntity> componentDependencies = componentDependencyModelManager.list(vspId, vspVersion); + MapComponentDependencyEntityToDto mapper = new MapComponentDependencyEntityToDto(); + GenericCollectionWrapper<ComponentDependencyResponseDto> results = new GenericCollectionWrapper<>(); + for (ComponentDependencyModelEntity entity : componentDependencies) { + results.add(mapper.applyMapping(entity, ComponentDependencyResponseDto.class)); + } + return Response.ok(results).build(); + } - MapComponentDependencyEntityToDto mapper = new MapComponentDependencyEntityToDto(); - ComponentDependencyResponseDto componentDependencyResponseDto = - mapper.applyMapping(componentDependencyModelEntity, ComponentDependencyResponseDto.class); + @Override + public Response delete(String vspId, String versionId, String dependencyId, String user) { + Version vspVersion = new Version(versionId); + componentDependencyModelManager.delete(vspId, vspVersion, dependencyId); + return Response.ok().build(); + } - return Response.ok(componentDependencyModelEntity != null ? componentDependencyResponseDto : - null).build(); - } + @Override + public Response update(ComponentDependencyModel request, String vspId, String versionId, String dependencyId, String user) { + final Version version = new Version(versionId); + ComponentDependencyModelEntity modelEntity = new MapComponentDependencyModelRequestToEntity() + .applyMapping(request, ComponentDependencyModelEntity.class); + modelEntity.setId(dependencyId); + modelEntity.setVspId(vspId); + modelEntity.setVersion(version); + componentDependencyModelManager.update(modelEntity); + return Response.ok().build(); + } + @Override + public Response get(String vspId, String version, String dependencyId, String user) { + ComponentDependencyModelEntity componentDependencyModelEntity = componentDependencyModelManager + .get(vspId, new Version(version), dependencyId); + MapComponentDependencyEntityToDto mapper = new MapComponentDependencyEntityToDto(); + ComponentDependencyResponseDto componentDependencyResponseDto = mapper + .applyMapping(componentDependencyModelEntity, ComponentDependencyResponseDto.class); + return Response.ok(componentDependencyModelEntity != null ? componentDependencyResponseDto : null).build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentMonitoringUploadsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentMonitoringUploadsImpl.java index 25c99b294b..64d36b95e0 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentMonitoringUploadsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentMonitoringUploadsImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.io.InputStream; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.openecomp.core.enrichment.types.MonitoringUploadType; import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; @@ -36,88 +38,67 @@ import org.openecomp.sdcrests.vsp.rest.mapping.MapMonitoringUploadStatusToDto; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.io.InputStream; - /** * @author katyr * @since June 26, 2017 */ - @Named @Service("componentMonitoringUploads") @Scope(value = "prototype") //@Validated public class ComponentMonitoringUploadsImpl implements ComponentMonitoringUploads { - private final MonitoringUploadsManager monitoringUploadsManager; - private final ComponentManager componentManager; - - public ComponentMonitoringUploadsImpl() { - this.monitoringUploadsManager = MonitoringUploadsManagerFactory.getInstance().createInterface(); - this.componentManager = ComponentManagerFactory.getInstance().createInterface(); - } - public ComponentMonitoringUploadsImpl(MonitoringUploadsManager monitoringUploadsManager, - ComponentManager componentManager) { - this.monitoringUploadsManager = monitoringUploadsManager; - this.componentManager = componentManager; - } + private final MonitoringUploadsManager monitoringUploadsManager; + private final ComponentManager componentManager; - @Override - public Response upload(Attachment attachment, - String vspId, String versionId, String componentId, String type, - String user) throws Exception { - - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - - MonitoringUploadType monitoringUploadType = getMonitoringUploadType(vspId, componentId, type); - monitoringUploadsManager.upload(attachment.getObject(InputStream.class), - attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, - monitoringUploadType); - return Response.ok().build(); - } - - private MonitoringUploadType getMonitoringUploadType(String vspId, String componentId, - String type) throws Exception { - MonitoringUploadType monitoringUploadType; - try { - monitoringUploadType = MonitoringUploadType.valueOf(type); - } catch (IllegalArgumentException exception) { - String errorWithParameters = ErrorMessagesFormatBuilder - .getErrorWithParameters(Messages.ILLEGAL_MONITORING_ARTIFACT_TYPE.getErrorMessage(), - componentId, vspId); - throw new Exception(errorWithParameters, exception); + public ComponentMonitoringUploadsImpl() { + this.monitoringUploadsManager = MonitoringUploadsManagerFactory.getInstance().createInterface(); + this.componentManager = ComponentManagerFactory.getInstance().createInterface(); } - return monitoringUploadType; - } - - @Override - public Response delete(String vspId, String versionId, String componentId, - String type, String user) throws Exception { - - MonitoringUploadType monitoringUploadType = getMonitoringUploadType(vspId, componentId, type); - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - monitoringUploadsManager.delete(vspId, version, componentId, monitoringUploadType); - return Response.ok().build(); - } + public ComponentMonitoringUploadsImpl(MonitoringUploadsManager monitoringUploadsManager, ComponentManager componentManager) { + this.monitoringUploadsManager = monitoringUploadsManager; + this.componentManager = componentManager; + } - @Override - public Response list(String vspId, String versionId, String componentId, - String user) { + @Override + public Response upload(Attachment attachment, String vspId, String versionId, String componentId, String type, String user) throws Exception { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + MonitoringUploadType monitoringUploadType = getMonitoringUploadType(vspId, componentId, type); + monitoringUploadsManager + .upload(attachment.getObject(InputStream.class), attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, + monitoringUploadType); + return Response.ok().build(); + } - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); + private MonitoringUploadType getMonitoringUploadType(String vspId, String componentId, String type) throws Exception { + MonitoringUploadType monitoringUploadType; + try { + monitoringUploadType = MonitoringUploadType.valueOf(type); + } catch (IllegalArgumentException exception) { + String errorWithParameters = ErrorMessagesFormatBuilder + .getErrorWithParameters(Messages.ILLEGAL_MONITORING_ARTIFACT_TYPE.getErrorMessage(), componentId, vspId); + throw new Exception(errorWithParameters, exception); + } + return monitoringUploadType; + } - MonitoringUploadStatus response = - monitoringUploadsManager.listFilenames(vspId, version, componentId); + @Override + public Response delete(String vspId, String versionId, String componentId, String type, String user) throws Exception { + MonitoringUploadType monitoringUploadType = getMonitoringUploadType(vspId, componentId, type); + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + monitoringUploadsManager.delete(vspId, version, componentId, monitoringUploadType); + return Response.ok().build(); + } - MonitoringUploadStatusDto returnEntity = - new MapMonitoringUploadStatusToDto() - .applyMapping(response, MonitoringUploadStatusDto.class); - return Response.status(Response.Status.OK).entity(returnEntity).build(); - } + @Override + public Response list(String vspId, String versionId, String componentId, String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + MonitoringUploadStatus response = monitoringUploadsManager.listFilenames(vspId, version, componentId); + MonitoringUploadStatusDto returnEntity = new MapMonitoringUploadStatusToDto().applyMapping(response, MonitoringUploadStatusDto.class); + return Response.status(Response.Status.OK).entity(returnEntity).build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java index 4e4d7d5d9e..ab0ad04075 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java @@ -13,9 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.io.File; +import java.io.InputStream; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.openecomp.sdc.activitylog.ActivityLogManager; import org.openecomp.sdc.activitylog.ActivityLogManagerFactory; @@ -37,165 +41,124 @@ import org.openecomp.sdcrests.wrappers.StringWrapperResponse; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.io.File; -import java.io.InputStream; -import java.util.Collection; - @Named @Service("componentProcesses") @Scope(value = "prototype") public class ComponentProcessesImpl implements ComponentProcesses { - private final ProcessManager processManager; - private final ComponentManager componentManager; - private final ActivityLogManager activityLogManager; - - public ComponentProcessesImpl() { - this.processManager = ProcessManagerFactory.getInstance().createInterface(); - this.componentManager = ComponentManagerFactory.getInstance().createInterface(); - this.activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); - } - - public ComponentProcessesImpl(ProcessManager processManager, - ComponentManager componentManager, ActivityLogManager activityLogManager) { - this.processManager = processManager; - this.componentManager = componentManager; - this.activityLogManager = activityLogManager; - } - - @Override - public Response list(String vspId, String versionId, String componentId, String user) { + private final ProcessManager processManager; + private final ComponentManager componentManager; + private final ActivityLogManager activityLogManager; - Version version = new Version(versionId); - validateComponentExistence(vspId, version, componentId, user); - Collection<ProcessEntity> processes = processManager.listProcesses(vspId, version, componentId); - - MapProcessEntityToProcessEntityDto mapper = new MapProcessEntityToProcessEntityDto(); - GenericCollectionWrapper<ProcessEntityDto> results = new GenericCollectionWrapper<>(); - for (ProcessEntity process : processes) { - results.add(mapper.applyMapping(process, ProcessEntityDto.class)); + public ComponentProcessesImpl() { + this.processManager = ProcessManagerFactory.getInstance().createInterface(); + this.componentManager = ComponentManagerFactory.getInstance().createInterface(); + this.activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); } - return Response.ok(results).build(); - } - - @Override - public Response deleteList(String vspId, String versionId, String componentId, String user) { - - Version version = new Version(versionId); - validateComponentExistence(vspId, version, componentId, user); - processManager.deleteProcesses(vspId, version, componentId); - - return Response.ok().build(); - } - - @Override - public Response create(ProcessRequestDto request, String vspId, String versionId, - String componentId, String user) { - - ProcessEntity process = - new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class); - process.setVspId(vspId); - process.setVersion(new Version(versionId)); - process.setComponentId(componentId); - - validateComponentExistence(vspId, process.getVersion(), componentId, user); - ProcessEntity createdProcess = processManager.createProcess(process); - - return Response - .ok(createdProcess != null ? new StringWrapperResponse(createdProcess.getId()) : null) - .build(); - } - - @Override - public Response get(String vspId, String versionId, String componentId, String processId, - String user) { - - Version version = new Version(versionId); - validateComponentExistence(vspId, version, componentId, user); - ProcessEntity process = processManager.getProcess(vspId, version, componentId, processId); - ProcessEntityDto result = - new MapProcessEntityToProcessEntityDto().applyMapping(process, ProcessEntityDto.class); - return Response.ok(result).build(); - } - - @Override - public Response delete(String vspId, String versionId, String componentId, String processId, - String user) { - - Version version = new Version(versionId); - validateComponentExistence(vspId, version, componentId, user); - processManager.deleteProcess(vspId, version, componentId, processId); - return Response.ok().build(); - } - - @Override - public Response update(ProcessRequestDto request, String vspId, String versionId, - String componentId, - String processId, String user) { - - ProcessEntity process = - new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class); - process.setVspId(vspId); - process.setVersion(new Version(versionId)); - process.setComponentId(componentId); - process.setId(processId); - validateComponentExistence(vspId, process.getVersion(), componentId, user); - processManager.updateProcess(process); - return Response.ok().build(); - } + public ComponentProcessesImpl(ProcessManager processManager, ComponentManager componentManager, ActivityLogManager activityLogManager) { + this.processManager = processManager; + this.componentManager = componentManager; + this.activityLogManager = activityLogManager; + } - @Override - public Response getUploadedFile(String vspId, String versionId, String componentId, - String processId, String user) { + @Override + public Response list(String vspId, String versionId, String componentId, String user) { + Version version = new Version(versionId); + validateComponentExistence(vspId, version, componentId, user); + Collection<ProcessEntity> processes = processManager.listProcesses(vspId, version, componentId); + MapProcessEntityToProcessEntityDto mapper = new MapProcessEntityToProcessEntityDto(); + GenericCollectionWrapper<ProcessEntityDto> results = new GenericCollectionWrapper<>(); + for (ProcessEntity process : processes) { + results.add(mapper.applyMapping(process, ProcessEntityDto.class)); + } + return Response.ok(results).build(); + } - Version vspVersion = new Version(versionId); - validateComponentExistence(vspId, vspVersion, componentId, user); - File file = processManager.getProcessArtifact(vspId, vspVersion, componentId, processId); + @Override + public Response deleteList(String vspId, String versionId, String componentId, String user) { + Version version = new Version(versionId); + validateComponentExistence(vspId, version, componentId, user); + processManager.deleteProcesses(vspId, version, componentId); + return Response.ok().build(); + } - Response.ResponseBuilder response = Response.ok(file); - if (file == null) { - return Response.status(Response.Status.NOT_FOUND).build(); + @Override + public Response create(ProcessRequestDto request, String vspId, String versionId, String componentId, String user) { + ProcessEntity process = new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class); + process.setVspId(vspId); + process.setVersion(new Version(versionId)); + process.setComponentId(componentId); + validateComponentExistence(vspId, process.getVersion(), componentId, user); + ProcessEntity createdProcess = processManager.createProcess(process); + return Response.ok(createdProcess != null ? new StringWrapperResponse(createdProcess.getId()) : null).build(); } - response.header("Content-Disposition", "attachment; filename=" + file.getName()); - return response.build(); - } - @Override - public Response deleteUploadedFile(String vspId, String versionId, String componentId, - String processId, - String user) { + @Override + public Response get(String vspId, String versionId, String componentId, String processId, String user) { + Version version = new Version(versionId); + validateComponentExistence(vspId, version, componentId, user); + ProcessEntity process = processManager.getProcess(vspId, version, componentId, processId); + ProcessEntityDto result = new MapProcessEntityToProcessEntityDto().applyMapping(process, ProcessEntityDto.class); + return Response.ok(result).build(); + } - Version version = new Version(versionId); - validateComponentExistence(vspId, version, componentId, user); - processManager.deleteProcessArtifact(vspId, version, componentId, processId); - return Response.ok().build(); - } + @Override + public Response delete(String vspId, String versionId, String componentId, String processId, String user) { + Version version = new Version(versionId); + validateComponentExistence(vspId, version, componentId, user); + processManager.deleteProcess(vspId, version, componentId, processId); + return Response.ok().build(); + } - @Override - public Response uploadFile(Attachment attachment, String vspId, String versionId, - String componentId, - String processId, String user) { + @Override + public Response update(ProcessRequestDto request, String vspId, String versionId, String componentId, String processId, String user) { + ProcessEntity process = new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class); + process.setVspId(vspId); + process.setVersion(new Version(versionId)); + process.setComponentId(componentId); + process.setId(processId); + validateComponentExistence(vspId, process.getVersion(), componentId, user); + processManager.updateProcess(process); + return Response.ok().build(); + } - Version version = new Version(versionId); - validateComponentExistence(vspId, version, componentId, user); - processManager.uploadProcessArtifact(attachment.getObject(InputStream.class), - attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, - processId); - activityLogManager.logActivity(new ActivityLogEntity(vspId, version, - ActivityType.Upload_Artifact, user, true, "", "")); + @Override + public Response getUploadedFile(String vspId, String versionId, String componentId, String processId, String user) { + Version vspVersion = new Version(versionId); + validateComponentExistence(vspId, vspVersion, componentId, user); + File file = processManager.getProcessArtifact(vspId, vspVersion, componentId, processId); + Response.ResponseBuilder response = Response.ok(file); + if (file == null) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + response.header("Content-Disposition", "attachment; filename=" + file.getName()); + return response.build(); + } - return Response.ok().build(); - } + @Override + public Response deleteUploadedFile(String vspId, String versionId, String componentId, String processId, String user) { + Version version = new Version(versionId); + validateComponentExistence(vspId, version, componentId, user); + processManager.deleteProcessArtifact(vspId, version, componentId, processId); + return Response.ok().build(); + } + @Override + public Response uploadFile(Attachment attachment, String vspId, String versionId, String componentId, String processId, String user) { + Version version = new Version(versionId); + validateComponentExistence(vspId, version, componentId, user); + processManager + .uploadProcessArtifact(attachment.getObject(InputStream.class), attachment.getContentDisposition().getParameter("filename"), vspId, + version, componentId, processId); + activityLogManager.logActivity(new ActivityLogEntity(vspId, version, ActivityType.Upload_Artifact, user, true, "", "")); + return Response.ok().build(); + } - private void validateComponentExistence(String vspId, Version version, String componentId, - String user) { - if (componentId == null) { - return; + private void validateComponentExistence(String vspId, Version version, String componentId, String user) { + if (componentId == null) { + return; + } + componentManager.validateComponentExistence(vspId, version, componentId); } - componentManager.validateComponentExistence(vspId, version, componentId); - } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java index fefa52842e..9f2cbd36b7 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; @@ -29,122 +31,104 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vsp.rest.Components; -import org.openecomp.sdcrests.vsp.rest.mapping.*; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDataToComponentDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentEntityToComponentCreationDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentEntityToComponentDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentRequestDtoToComponentEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("components") @Scope(value = "prototype") public class ComponentsImpl implements Components { - private final ComponentManager componentManager; - - public ComponentsImpl() { - this.componentManager = ComponentManagerFactory.getInstance().createInterface(); - } - - public ComponentsImpl(ComponentManager componentManager) { - this.componentManager = componentManager; - } - @Override - public Response list(String vspId, String versionId, String user) { + private final ComponentManager componentManager; - Collection<ComponentEntity> components = - componentManager.listComponents(vspId, new Version(versionId)); - - MapComponentEntityToComponentDto mapper = new MapComponentEntityToComponentDto(); - GenericCollectionWrapper<ComponentDto> results = new GenericCollectionWrapper<>(); - for (ComponentEntity component : components) { - results.add(mapper.applyMapping(component, ComponentDto.class)); + public ComponentsImpl() { + this.componentManager = ComponentManagerFactory.getInstance().createInterface(); } - return Response.ok(results).build(); - } - - @Override - public Response deleteList(String vspId, String versionId, String user) { - componentManager.deleteComponents(vspId, new Version(versionId)); - return Response.ok().build(); - } - - @Override - public Response create(ComponentRequestDto request, String vspId, String versionId, String user) { - - ComponentEntity component = - new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class); - component.setVspId(vspId); - component.setVersion(new Version(versionId)); - - ComponentEntity createdComponent = componentManager.createComponent(component); - MapComponentEntityToComponentCreationDto mapping = - new MapComponentEntityToComponentCreationDto(); - ComponentCreationDto createdComponentDto = mapping.applyMapping(createdComponent, - ComponentCreationDto.class); - return Response - .ok(createdComponent != null ? createdComponentDto : null) - .build(); - } - - @Override - public Response get(String vspId, String versionId, String componentId, String user) { + public ComponentsImpl(ComponentManager componentManager) { + this.componentManager = componentManager; + } - CompositionEntityResponse<ComponentData> response = - componentManager.getComponent(vspId, new Version(versionId), componentId); + @Override + public Response list(String vspId, String versionId, String user) { + Collection<ComponentEntity> components = componentManager.listComponents(vspId, new Version(versionId)); + MapComponentEntityToComponentDto mapper = new MapComponentEntityToComponentDto(); + GenericCollectionWrapper<ComponentDto> results = new GenericCollectionWrapper<>(); + for (ComponentEntity component : components) { + results.add(mapper.applyMapping(component, ComponentDto.class)); + } + return Response.ok(results).build(); + } - CompositionEntityResponseDto<ComponentDto> responseDto = new CompositionEntityResponseDto<>(); - new MapCompositionEntityResponseToDto<>(new MapComponentDataToComponentDto(), - ComponentDto.class).doMapping(response, responseDto); - return Response.ok(responseDto).build(); - } + @Override + public Response deleteList(String vspId, String versionId, String user) { + componentManager.deleteComponents(vspId, new Version(versionId)); + return Response.ok().build(); + } - @Override - public Response delete(String vspId, String versionId, String componentId, String user) { - componentManager.deleteComponent(vspId, new Version(versionId), componentId); - return Response.ok().build(); - } + @Override + public Response create(ComponentRequestDto request, String vspId, String versionId, String user) { + ComponentEntity component = new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class); + component.setVspId(vspId); + component.setVersion(new Version(versionId)); + ComponentEntity createdComponent = componentManager.createComponent(component); + MapComponentEntityToComponentCreationDto mapping = new MapComponentEntityToComponentCreationDto(); + ComponentCreationDto createdComponentDto = mapping.applyMapping(createdComponent, ComponentCreationDto.class); + return Response.ok(createdComponent != null ? createdComponentDto : null).build(); + } - @Override - public Response update(ComponentRequestDto request, String vspId, String versionId, - String componentId, - String user) { - ComponentEntity componentEntity = - new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class); - componentEntity.setVspId(vspId); - componentEntity.setVersion(new Version(versionId)); - componentEntity.setId(componentId); + @Override + public Response get(String vspId, String versionId, String componentId, String user) { + CompositionEntityResponse<ComponentData> response = componentManager.getComponent(vspId, new Version(versionId), componentId); + CompositionEntityResponseDto<ComponentDto> responseDto = new CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapComponentDataToComponentDto(), ComponentDto.class).doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } - CompositionEntityValidationData validationData = - componentManager.updateComponent(componentEntity); - return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) - ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto().applyMapping(validationData, - CompositionEntityValidationDataDto.class)).build() : Response.ok().build(); - } + @Override + public Response delete(String vspId, String versionId, String componentId, String user) { + componentManager.deleteComponent(vspId, new Version(versionId), componentId); + return Response.ok().build(); + } - @Override - public Response getQuestionnaire(String vspId, String versionId, String componentId, - String user) { - QuestionnaireResponse questionnaireResponse = - componentManager.getQuestionnaire(vspId, new Version(versionId), componentId); + @Override + public Response update(ComponentRequestDto request, String vspId, String versionId, String componentId, String user) { + ComponentEntity componentEntity = new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class); + componentEntity.setVspId(vspId); + componentEntity.setVersion(new Version(versionId)); + componentEntity.setId(componentId); + CompositionEntityValidationData validationData = componentManager.updateComponent(componentEntity); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapCompositionEntityValidationDataToDto().applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() + : Response.ok().build(); + } - QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() - .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); - return Response.ok(result).build(); - } + @Override + public Response getQuestionnaire(String vspId, String versionId, String componentId, String user) { + QuestionnaireResponse questionnaireResponse = componentManager.getQuestionnaire(vspId, new Version(versionId), componentId); + QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + return Response.ok(result).build(); + } - @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, - String componentId, String user) { - componentManager - .updateQuestionnaire(vspId, new Version(versionId), componentId, questionnaireData); - return Response.ok().build(); - } + @Override + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String componentId, String user) { + componentManager.updateQuestionnaire(vspId, new Version(versionId), componentId, questionnaireData); + return Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComputeImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComputeImpl.java index 1eea42803b..8c06629849 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComputeImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComputeImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; @@ -32,137 +34,116 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData; import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDetailsDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComputeDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vsp.rest.Compute; -import org.openecomp.sdcrests.vsp.rest.mapping.*; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeDataToComputeDetailsDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeDetailsDtoToComputeEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToComputeCreationDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToComputeDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("computes") @Scope(value = "prototype") public class ComputeImpl implements Compute { - private final ComputeManager computetManager; - private final ComponentManager componentManager; - public ComputeImpl() { - this.computetManager = ComputeManagerFactory.getInstance().createInterface(); - this.componentManager = ComponentManagerFactory.getInstance().createInterface(); - } + private final ComputeManager computetManager; + private final ComponentManager componentManager; - public ComputeImpl(ComputeManager computetManager, ComponentManager componentManager) { - this.computetManager = computetManager; - this.componentManager = componentManager; - } - - @Override - public Response list(String vspId, String versionId, String componentId, String user) { - - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - Collection<ListComputeResponse> computes = - computetManager.listComputes(vspId, version, componentId); - - MapComputeEntityToComputeDto mapper = new MapComputeEntityToComputeDto(); - GenericCollectionWrapper<ComputeDto> results = new GenericCollectionWrapper<>(); - for (ListComputeResponse compute : computes) { - results.add(mapper.applyMapping(compute, ComputeDto.class)); + public ComputeImpl() { + this.computetManager = ComputeManagerFactory.getInstance().createInterface(); + this.componentManager = ComponentManagerFactory.getInstance().createInterface(); } - return Response.ok(results).build(); - } - - @Override - public Response get(String vspId, String versionId, String componentId, String computeId, - String user) { - - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - CompositionEntityResponse<ComputeData> response = - computetManager.getCompute(vspId, version, componentId, computeId); - - CompositionEntityResponseDto<ComputeDetailsDto> responseDto = new - CompositionEntityResponseDto<>(); - new MapCompositionEntityResponseToDto<>(new MapComputeDataToComputeDetailsDto(), - ComputeDetailsDto.class).doMapping(response, responseDto); - return Response.ok(responseDto).build(); - } - - @Override - public Response create(ComputeDetailsDto request, String vspId, String versionId, - String componentId, String user) { - - ComputeEntity compute = new MapComputeDetailsDtoToComputeEntity().applyMapping(request, - ComputeEntity.class); - compute.setVspId(vspId); - compute.setVersion(new Version(versionId)); - compute.setComponentId(componentId); - componentManager.validateComponentExistence(vspId, compute.getVersion(), componentId); - - ComputeEntity createdCompute = computetManager.createCompute(compute); - - MapComputeEntityToComputeCreationDto mapper = new MapComputeEntityToComputeCreationDto(); - ComputeCreationDto createdComputeDto = - mapper.applyMapping(createdCompute, ComputeCreationDto.class); - return Response.ok(createdComputeDto != null ? createdComputeDto : null).build(); - } - - @Override - public Response update(ComputeDetailsDto request, String vspId, String versionId, - String componentId, String computeFlavorId, String user) { - - ComputeEntity compute = - new MapComputeDetailsDtoToComputeEntity().applyMapping(request, ComputeEntity.class); - compute.setVspId(vspId); - compute.setVersion(new Version(versionId)); - compute.setComponentId(componentId); - compute.setId(computeFlavorId); - - componentManager.validateComponentExistence(vspId, compute.getVersion(), componentId); - CompositionEntityValidationData validationData = computetManager.updateCompute(compute); - return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) - ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto().applyMapping(validationData, - CompositionEntityValidationDataDto.class)).build() : Response.ok().build(); - } + public ComputeImpl(ComputeManager computetManager, ComponentManager componentManager) { + this.computetManager = computetManager; + this.componentManager = componentManager; + } - @Override - public Response delete(String vspId, String versionId, String componentId, String computeFlavorId, - String user) { + @Override + public Response list(String vspId, String versionId, String componentId, String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + Collection<ListComputeResponse> computes = computetManager.listComputes(vspId, version, componentId); + MapComputeEntityToComputeDto mapper = new MapComputeEntityToComputeDto(); + GenericCollectionWrapper<ComputeDto> results = new GenericCollectionWrapper<>(); + for (ListComputeResponse compute : computes) { + results.add(mapper.applyMapping(compute, ComputeDto.class)); + } + return Response.ok(results).build(); + } - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - computetManager.deleteCompute(vspId, version, componentId, computeFlavorId); - return Response.ok().build(); - } + @Override + public Response get(String vspId, String versionId, String componentId, String computeId, String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + CompositionEntityResponse<ComputeData> response = computetManager.getCompute(vspId, version, componentId, computeId); + CompositionEntityResponseDto<ComputeDetailsDto> responseDto = new CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapComputeDataToComputeDetailsDto(), ComputeDetailsDto.class).doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } - @Override - public Response getQuestionnaire(String vspId, String versionId, String componentId, - String computeFlavorId, String user) { + @Override + public Response create(ComputeDetailsDto request, String vspId, String versionId, String componentId, String user) { + ComputeEntity compute = new MapComputeDetailsDtoToComputeEntity().applyMapping(request, ComputeEntity.class); + compute.setVspId(vspId); + compute.setVersion(new Version(versionId)); + compute.setComponentId(componentId); + componentManager.validateComponentExistence(vspId, compute.getVersion(), componentId); + ComputeEntity createdCompute = computetManager.createCompute(compute); + MapComputeEntityToComputeCreationDto mapper = new MapComputeEntityToComputeCreationDto(); + ComputeCreationDto createdComputeDto = mapper.applyMapping(createdCompute, ComputeCreationDto.class); + return Response.ok(createdComputeDto != null ? createdComputeDto : null).build(); + } - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - QuestionnaireResponse questionnaireResponse = - computetManager.getComputeQuestionnaire(vspId, version, componentId, computeFlavorId); + @Override + public Response update(ComputeDetailsDto request, String vspId, String versionId, String componentId, String computeFlavorId, String user) { + ComputeEntity compute = new MapComputeDetailsDtoToComputeEntity().applyMapping(request, ComputeEntity.class); + compute.setVspId(vspId); + compute.setVersion(new Version(versionId)); + compute.setComponentId(componentId); + compute.setId(computeFlavorId); + componentManager.validateComponentExistence(vspId, compute.getVersion(), componentId); + CompositionEntityValidationData validationData = computetManager.updateCompute(compute); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapCompositionEntityValidationDataToDto().applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() + : Response.ok().build(); + } - QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() - .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); - return Response.ok(result).build(); - } + @Override + public Response delete(String vspId, String versionId, String componentId, String computeFlavorId, String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + computetManager.deleteCompute(vspId, version, componentId, computeFlavorId); + return Response.ok().build(); + } - @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, - String componentId, String computeFlavorId, String user) { + @Override + public Response getQuestionnaire(String vspId, String versionId, String componentId, String computeFlavorId, String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + QuestionnaireResponse questionnaireResponse = computetManager.getComputeQuestionnaire(vspId, version, componentId, computeFlavorId); + QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + return Response.ok(result).build(); + } - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - computetManager.updateComputeQuestionnaire(vspId, version, componentId, computeFlavorId, - questionnaireData); - return Response.ok().build(); - } + @Override + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String componentId, String computeFlavorId, + String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + computetManager.updateComputeQuestionnaire(vspId, version, componentId, computeFlavorId, questionnaireData); + return Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/DeploymentFlavorsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/DeploymentFlavorsImpl.java index 13851e72e1..1f022aee18 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/DeploymentFlavorsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/DeploymentFlavorsImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManager; import org.openecomp.sdc.vendorsoftwareproduct.DeploymentFlavorManagerFactory; @@ -28,108 +30,93 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor; import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorListResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.DeploymentFlavorRequestDto; import org.openecomp.sdcrests.vsp.rest.DeploymentFlavors; -import org.openecomp.sdcrests.vsp.rest.mapping.*; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorEntityDeploymentFlavorToListResponse; +import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorEntityToDeploymentFlavorCreationDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapDeploymentFlavorToDeploymentDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("deploymentFlavors") @Scope(value = "prototype") public class DeploymentFlavorsImpl implements DeploymentFlavors { - private final DeploymentFlavorManager deploymentFlavorManager; - - public DeploymentFlavorsImpl() { - this.deploymentFlavorManager = - DeploymentFlavorManagerFactory.getInstance().createInterface(); - } - - public DeploymentFlavorsImpl(DeploymentFlavorManager deploymentFlavorManager) { - this.deploymentFlavorManager = deploymentFlavorManager; - } - @Override - public Response create(DeploymentFlavorRequestDto request, String vspId, String versionId, - String user) { - DeploymentFlavorEntity deploymentFlavorEntity = - new MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity() - .applyMapping(request, DeploymentFlavorEntity.class); - deploymentFlavorEntity.setVspId(vspId); - deploymentFlavorEntity.setVersion(new Version(versionId)); - DeploymentFlavorEntity createdDeploymentFlavor = - deploymentFlavorManager.createDeploymentFlavor(deploymentFlavorEntity); - MapDeploymentFlavorEntityToDeploymentFlavorCreationDto mapping = - new MapDeploymentFlavorEntityToDeploymentFlavorCreationDto(); - DeploymentFlavorCreationDto deploymentFlavorCreatedDto = mapping.applyMapping - (createdDeploymentFlavor, DeploymentFlavorCreationDto.class); - return Response - .ok(createdDeploymentFlavor != null ? deploymentFlavorCreatedDto : null) - .build(); - } + private final DeploymentFlavorManager deploymentFlavorManager; - @Override - public Response list(String vspId, String versionId, String user) { - Collection<DeploymentFlavorEntity> deploymentFlavors = - deploymentFlavorManager.listDeploymentFlavors(vspId, new Version(versionId)); + public DeploymentFlavorsImpl() { + this.deploymentFlavorManager = DeploymentFlavorManagerFactory.getInstance().createInterface(); + } - MapDeploymentFlavorEntityDeploymentFlavorToListResponse mapper = new - MapDeploymentFlavorEntityDeploymentFlavorToListResponse(); - GenericCollectionWrapper<DeploymentFlavorListResponseDto> results = - new GenericCollectionWrapper<>(); - for (DeploymentFlavorEntity deploymentFlavor : deploymentFlavors) { - results.add(mapper.applyMapping(deploymentFlavor, DeploymentFlavorListResponseDto.class)); + public DeploymentFlavorsImpl(DeploymentFlavorManager deploymentFlavorManager) { + this.deploymentFlavorManager = deploymentFlavorManager; } - return Response.ok(results).build(); - } - @Override - public Response get(String vspId, String versionId, String deploymentFlavorId, String user) { - CompositionEntityResponse<DeploymentFlavor> response = deploymentFlavorManager - .getDeploymentFlavor(vspId, new Version(versionId), deploymentFlavorId); + @Override + public Response create(DeploymentFlavorRequestDto request, String vspId, String versionId, String user) { + DeploymentFlavorEntity deploymentFlavorEntity = new MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity() + .applyMapping(request, DeploymentFlavorEntity.class); + deploymentFlavorEntity.setVspId(vspId); + deploymentFlavorEntity.setVersion(new Version(versionId)); + DeploymentFlavorEntity createdDeploymentFlavor = deploymentFlavorManager.createDeploymentFlavor(deploymentFlavorEntity); + MapDeploymentFlavorEntityToDeploymentFlavorCreationDto mapping = new MapDeploymentFlavorEntityToDeploymentFlavorCreationDto(); + DeploymentFlavorCreationDto deploymentFlavorCreatedDto = mapping.applyMapping(createdDeploymentFlavor, DeploymentFlavorCreationDto.class); + return Response.ok(createdDeploymentFlavor != null ? deploymentFlavorCreatedDto : null).build(); + } - CompositionEntityResponseDto<DeploymentFlavorDto> responseDto = new - CompositionEntityResponseDto<>(); - new MapCompositionEntityResponseToDto<>(new MapDeploymentFlavorToDeploymentDto(), - DeploymentFlavorDto.class) - .doMapping(response, responseDto); - return Response.ok(responseDto).build(); - } + @Override + public Response list(String vspId, String versionId, String user) { + Collection<DeploymentFlavorEntity> deploymentFlavors = deploymentFlavorManager.listDeploymentFlavors(vspId, new Version(versionId)); + MapDeploymentFlavorEntityDeploymentFlavorToListResponse mapper = new MapDeploymentFlavorEntityDeploymentFlavorToListResponse(); + GenericCollectionWrapper<DeploymentFlavorListResponseDto> results = new GenericCollectionWrapper<>(); + for (DeploymentFlavorEntity deploymentFlavor : deploymentFlavors) { + results.add(mapper.applyMapping(deploymentFlavor, DeploymentFlavorListResponseDto.class)); + } + return Response.ok(results).build(); + } - @Override - public Response getSchema(String vspId, String versionId, String user) { - CompositionEntityResponse<DeploymentFlavor> response = deploymentFlavorManager - .getDeploymentFlavorSchema(vspId, new Version(versionId)); - return Response.ok(response).build(); - } + @Override + public Response get(String vspId, String versionId, String deploymentFlavorId, String user) { + CompositionEntityResponse<DeploymentFlavor> response = deploymentFlavorManager + .getDeploymentFlavor(vspId, new Version(versionId), deploymentFlavorId); + CompositionEntityResponseDto<DeploymentFlavorDto> responseDto = new CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapDeploymentFlavorToDeploymentDto(), DeploymentFlavorDto.class).doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } - @Override - public Response delete(String vspId, String versionId, String deploymentFlavorId, String user) { - Version version = new Version(versionId); - deploymentFlavorManager.deleteDeploymentFlavor(vspId, version, deploymentFlavorId); - return Response.ok().build(); - } + @Override + public Response getSchema(String vspId, String versionId, String user) { + CompositionEntityResponse<DeploymentFlavor> response = deploymentFlavorManager.getDeploymentFlavorSchema(vspId, new Version(versionId)); + return Response.ok(response).build(); + } - @Override - public Response update(DeploymentFlavorRequestDto request, String vspId, String versionId, - String deploymentFlavorId, String user) { - DeploymentFlavorEntity deploymentFlavorEntity = - new MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity().applyMapping(request, - DeploymentFlavorEntity.class); - deploymentFlavorEntity.setVspId(vspId); - deploymentFlavorEntity.setVersion(new Version(versionId)); - deploymentFlavorEntity.setId(deploymentFlavorId); + @Override + public Response delete(String vspId, String versionId, String deploymentFlavorId, String user) { + Version version = new Version(versionId); + deploymentFlavorManager.deleteDeploymentFlavor(vspId, version, deploymentFlavorId); + return Response.ok().build(); + } - CompositionEntityValidationData validationData = - deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity); - return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) - ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto().applyMapping(validationData, - CompositionEntityValidationDataDto.class)).build() : Response.ok().build(); - } + @Override + public Response update(DeploymentFlavorRequestDto request, String vspId, String versionId, String deploymentFlavorId, String user) { + DeploymentFlavorEntity deploymentFlavorEntity = new MapDeploymentFlavorRequestDtoToDeploymentFlavorEntity() + .applyMapping(request, DeploymentFlavorEntity.class); + deploymentFlavorEntity.setVspId(vspId); + deploymentFlavorEntity.setVersion(new Version(versionId)); + deploymentFlavorEntity.setId(deploymentFlavorId); + CompositionEntityValidationData validationData = deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapCompositionEntityValidationDataToDto().applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() + : Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImpl.java index 7971b48427..350630c0aa 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ImagesImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,10 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.services; - +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections.CollectionUtils; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; @@ -32,135 +33,116 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image; import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageCreationDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ImageRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vsp.rest.Images; -import org.openecomp.sdcrests.vsp.rest.mapping.*; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapImageEntityToImageCreationDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapImageEntityToImageDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapImageRequestDtoToImageEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - - @Named @Service("images") @Scope(value = "prototype") public class ImagesImpl implements Images { - private final ImageManager imageManager; - private final ComponentManager componentManager; - - public ImagesImpl() { - this.imageManager = ImageManagerFactory.getInstance().createInterface(); - this.componentManager = - ComponentManagerFactory.getInstance().createInterface(); - } - - public ImagesImpl(ImageManager imageManager, ComponentManager componentManager) { - this.imageManager = imageManager; - this.componentManager = componentManager; - } - - @Override - public Response create(ImageRequestDto request, String vspId, String versionId, - String componentId, String user) { - ImageEntity image = - new MapImageRequestDtoToImageEntity().applyMapping(request, ImageEntity.class); - image.setVspId(vspId); - image.setComponentId(componentId); - image.setVersion(new Version(versionId)); - componentManager.validateComponentExistence(vspId, image.getVersion(), componentId); - ImageEntity createdImage = imageManager.createImage(image); - MapImageEntityToImageCreationDto mapping = new MapImageEntityToImageCreationDto(); - ImageCreationDto createdImageDto = mapping.applyMapping(createdImage, ImageCreationDto.class); - return Response - .ok(createdImage != null ? createdImageDto : null) - .build(); - } + private final ImageManager imageManager; + private final ComponentManager componentManager; - @Override - public Response getImageSchema(String vspId, String versionId, String componentId, String user) { - CompositionEntityResponse<Image> response = imageManager.getImageSchema(vspId); - return Response.ok(response).build(); - } - - @Override - public Response get(String vspId, String versionId, String componentId, String imageId, - String user) { - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - CompositionEntityResponse<Image> response = - imageManager.getImage(vspId, version, componentId, imageId); - - return Response.ok(response).build(); - } - - @Override - public Response list(String vspId, String versionId, String componentId, String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - Collection<ImageEntity> images = imageManager.listImages(vspId, vspVersion, componentId); - - MapImageEntityToImageDto mapper = new MapImageEntityToImageDto(); - GenericCollectionWrapper<ImageDto> results = new GenericCollectionWrapper<>(); - for (ImageEntity image : images) { - results.add(mapper.applyMapping(image, ImageDto.class)); + public ImagesImpl() { + this.imageManager = ImageManagerFactory.getInstance().createInterface(); + this.componentManager = ComponentManagerFactory.getInstance().createInterface(); } - return Response.ok(results).build(); - } + public ImagesImpl(ImageManager imageManager, ComponentManager componentManager) { + this.imageManager = imageManager; + this.componentManager = componentManager; + } - @Override - public Response delete(String vspId, String versionId, String componentId, String imageId, - String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - imageManager.deleteImage(vspId, vspVersion, componentId, imageId); - return Response.ok().build(); - } + @Override + public Response create(ImageRequestDto request, String vspId, String versionId, String componentId, String user) { + ImageEntity image = new MapImageRequestDtoToImageEntity().applyMapping(request, ImageEntity.class); + image.setVspId(vspId); + image.setComponentId(componentId); + image.setVersion(new Version(versionId)); + componentManager.validateComponentExistence(vspId, image.getVersion(), componentId); + ImageEntity createdImage = imageManager.createImage(image); + MapImageEntityToImageCreationDto mapping = new MapImageEntityToImageCreationDto(); + ImageCreationDto createdImageDto = mapping.applyMapping(createdImage, ImageCreationDto.class); + return Response.ok(createdImage != null ? createdImageDto : null).build(); + } - @Override - public Response update(ImageRequestDto request, String vspId, String versionId, - String componentId, String imageId, String user) { - ImageEntity imageEntity = new MapImageRequestDtoToImageEntity().applyMapping(request, - ImageEntity.class); - imageEntity.setVspId(vspId); - imageEntity.setVersion(new Version(versionId)); - imageEntity.setComponentId(componentId); - imageEntity.setId(imageId); - componentManager.validateComponentExistence(vspId, imageEntity.getVersion(), componentId); + @Override + public Response getImageSchema(String vspId, String versionId, String componentId, String user) { + CompositionEntityResponse<Image> response = imageManager.getImageSchema(vspId); + return Response.ok(response).build(); + } - CompositionEntityValidationData validationData = imageManager.updateImage(imageEntity); - return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) - ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto() - .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : - Response.ok().build(); - } + @Override + public Response get(String vspId, String versionId, String componentId, String imageId, String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + CompositionEntityResponse<Image> response = imageManager.getImage(vspId, version, componentId, imageId); + return Response.ok(response).build(); + } - @Override - public Response getQuestionnaire(String vspId, String versionId, String componentId, - String imageId, String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - QuestionnaireResponse questionnaireResponse = - imageManager.getImageQuestionnaire(vspId, vspVersion, componentId, imageId); + @Override + public Response list(String vspId, String versionId, String componentId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + Collection<ImageEntity> images = imageManager.listImages(vspId, vspVersion, componentId); + MapImageEntityToImageDto mapper = new MapImageEntityToImageDto(); + GenericCollectionWrapper<ImageDto> results = new GenericCollectionWrapper<>(); + for (ImageEntity image : images) { + results.add(mapper.applyMapping(image, ImageDto.class)); + } + return Response.ok(results).build(); + } - QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() - .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); - return Response.ok(result).build(); + @Override + public Response delete(String vspId, String versionId, String componentId, String imageId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + imageManager.deleteImage(vspId, vspVersion, componentId, imageId); + return Response.ok().build(); + } - } + @Override + public Response update(ImageRequestDto request, String vspId, String versionId, String componentId, String imageId, String user) { + ImageEntity imageEntity = new MapImageRequestDtoToImageEntity().applyMapping(request, ImageEntity.class); + imageEntity.setVspId(vspId); + imageEntity.setVersion(new Version(versionId)); + imageEntity.setComponentId(componentId); + imageEntity.setId(imageId); + componentManager.validateComponentExistence(vspId, imageEntity.getVersion(), componentId); + CompositionEntityValidationData validationData = imageManager.updateImage(imageEntity); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapCompositionEntityValidationDataToDto().applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() + : Response.ok().build(); + } - @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, - String componentId, String imageId, String user) { - Version version = new Version(versionId); - componentManager.validateComponentExistence(vspId, version, componentId); - imageManager.updateImageQuestionnaire(vspId, version, componentId, imageId, questionnaireData); - return Response.ok().build(); - } + @Override + public Response getQuestionnaire(String vspId, String versionId, String componentId, String imageId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + QuestionnaireResponse questionnaireResponse = imageManager.getImageQuestionnaire(vspId, vspVersion, componentId, imageId); + QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + return Response.ok(result).build(); + } + @Override + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String componentId, String imageId, String user) { + Version version = new Version(versionId); + componentManager.validateComponentExistence(vspId, version, componentId); + imageManager.updateImageQuestionnaire(vspId, version, componentId, imageId, questionnaireData); + return Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java index 6a6cbd0e60..e25ef8e324 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.vendorsoftwareproduct.NetworkManager; import org.openecomp.sdc.vendorsoftwareproduct.NetworkManagerFactory; @@ -33,93 +35,74 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityVali import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkRequestDto; import org.openecomp.sdcrests.vsp.rest.Networks; -import org.openecomp.sdcrests.vsp.rest.mapping.*; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkEntityToNetworkDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkRequestDtoToNetworkEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkToNetworkDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("networks") @Scope(value = "prototype") public class NetworksImpl implements Networks { - private final NetworkManager networkManager; - - public NetworksImpl(NetworkManager networkManager) { - this.networkManager = networkManager; - } + private final NetworkManager networkManager; - public NetworksImpl() { - this(NetworkManagerFactory.getInstance().createInterface()); - } - - @Override - public Response list(String vspId, String versionId, String user) { - Collection<NetworkEntity> networks = - networkManager.listNetworks(vspId, new Version(versionId)); - - MapNetworkEntityToNetworkDto mapper = new MapNetworkEntityToNetworkDto(); - GenericCollectionWrapper<NetworkDto> results = new GenericCollectionWrapper<>(); - for (NetworkEntity network : networks) { - results.add(mapper.applyMapping(network, NetworkDto.class)); + public NetworksImpl(NetworkManager networkManager) { + this.networkManager = networkManager; } - return Response.ok(results).build(); - } - - @Override - public Response create(NetworkRequestDto request, String vspId, String versionId, String user) { - NetworkEntity network = - new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class); - network.setVspId(vspId); - network.setVersion(new Version(versionId)); - NetworkEntity createdNetwork = networkManager.createNetwork(network); - return Response - .ok(createdNetwork != null ? new StringWrapperResponse(createdNetwork.getId()) : null) - .build(); - } + public NetworksImpl() { + this(NetworkManagerFactory.getInstance().createInterface()); + } - @Override - public Response get(String vspId, String versionId, String networkId, String user) { - CompositionEntityResponse<Network> response = - networkManager.getNetwork(vspId, - new Version(versionId), networkId - ); + @Override + public Response list(String vspId, String versionId, String user) { + Collection<NetworkEntity> networks = networkManager.listNetworks(vspId, new Version(versionId)); + MapNetworkEntityToNetworkDto mapper = new MapNetworkEntityToNetworkDto(); + GenericCollectionWrapper<NetworkDto> results = new GenericCollectionWrapper<>(); + for (NetworkEntity network : networks) { + results.add(mapper.applyMapping(network, NetworkDto.class)); + } + return Response.ok(results).build(); + } - CompositionEntityResponseDto<NetworkDto> responseDto = new CompositionEntityResponseDto<>(); - new MapCompositionEntityResponseToDto<>(new MapNetworkToNetworkDto(), NetworkDto.class) - .doMapping(response, responseDto); - return Response.ok(responseDto).build(); - } + @Override + public Response create(NetworkRequestDto request, String vspId, String versionId, String user) { + NetworkEntity network = new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class); + network.setVspId(vspId); + network.setVersion(new Version(versionId)); + NetworkEntity createdNetwork = networkManager.createNetwork(network); + return Response.ok(createdNetwork != null ? new StringWrapperResponse(createdNetwork.getId()) : null).build(); + } - @Override - public Response delete(String vspId, String versionId, String networkId, String user) { - networkManager - .deleteNetwork(vspId, new Version(versionId), - networkId); - return Response.ok().build(); - } + @Override + public Response get(String vspId, String versionId, String networkId, String user) { + CompositionEntityResponse<Network> response = networkManager.getNetwork(vspId, new Version(versionId), networkId); + CompositionEntityResponseDto<NetworkDto> responseDto = new CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapNetworkToNetworkDto(), NetworkDto.class).doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } - @Override - public Response update(NetworkRequestDto request, String vspId, String versionId, - String networkId, String user) { - NetworkEntity networkEntity = - new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class); - networkEntity.setVspId(vspId); - networkEntity.setVersion(new Version(versionId)); - networkEntity.setId(networkId); + @Override + public Response delete(String vspId, String versionId, String networkId, String user) { + networkManager.deleteNetwork(vspId, new Version(versionId), networkId); + return Response.ok().build(); + } - CompositionEntityValidationData validationData = - networkManager.updateNetwork(networkEntity); - return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) - ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto() - .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : - Response.ok().build(); - } + @Override + public Response update(NetworkRequestDto request, String vspId, String versionId, String networkId, String user) { + NetworkEntity networkEntity = new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class); + networkEntity.setVspId(vspId); + networkEntity.setVersion(new Version(versionId)); + networkEntity.setId(networkId); + CompositionEntityValidationData validationData = networkManager.updateNetwork(networkEntity); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapCompositionEntityValidationDataToDto().applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() + : Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java index 11ed508286..9784015089 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,9 +17,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vsp.rest.services; +import java.util.Collection; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; @@ -31,131 +33,115 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicCreationResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; import org.openecomp.sdcrests.vsp.rest.Nics; -import org.openecomp.sdcrests.vsp.rest.mapping.*; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDataToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNicEntityToNicCreationResponseDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNicEntityToNicDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNicRequestDtoToNicEntity; +import org.openecomp.sdcrests.vsp.rest.mapping.MapNicToNicDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.util.Collection; - @Named @Service("nics") @Scope(value = "prototype") public class NicsImpl implements Nics { - private final NicManager nicManager; - private final ComponentManager componentManager; - - public NicsImpl() { - this.nicManager = NicManagerFactory.getInstance().createInterface(); - this.componentManager = ComponentManagerFactory.getInstance().createInterface(); - } - public NicsImpl(NicManager nicManager, ComponentManager componentManager) { - this.nicManager = nicManager; - this.componentManager = componentManager; - } + private final NicManager nicManager; + private final ComponentManager componentManager; - @Override - public Response list(String vspId, String versionId, String componentId, String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - Collection<NicEntity> nics = nicManager.listNics(vspId, vspVersion, componentId); - - MapNicEntityToNicDto mapper = new MapNicEntityToNicDto(); - GenericCollectionWrapper<NicDto> results = new GenericCollectionWrapper<>(); - for (NicEntity nic : nics) { - results.add(mapper.applyMapping(nic, NicDto.class)); + public NicsImpl() { + this.nicManager = NicManagerFactory.getInstance().createInterface(); + this.componentManager = ComponentManagerFactory.getInstance().createInterface(); } - return Response.ok(results).build(); - } - - @Override - public Response create(NicRequestDto request, String vspId, String versionId, String componentId, - String user) { - NicEntity nic = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class); - nic.setVspId(vspId); - nic.setVersion(new Version(versionId)); - nic.setComponentId(componentId); - componentManager.validateComponentExistence(vspId, nic.getVersion(), componentId); - - NicEntity createdNic = nicManager.createNic(nic); - MapNicEntityToNicCreationResponseDto mapping = - new MapNicEntityToNicCreationResponseDto(); - NicCreationResponseDto createdNicDto = mapping.applyMapping(createdNic, - NicCreationResponseDto.class); - return Response.ok(createdNic != null ? createdNicDto : null) - .build(); - } - - @Override - public Response get(String vspId, String versionId, String componentId, String nicId, - String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - CompositionEntityResponse<Nic> response = - nicManager.getNic(vspId, vspVersion, componentId, nicId); + public NicsImpl(NicManager nicManager, ComponentManager componentManager) { + this.nicManager = nicManager; + this.componentManager = componentManager; + } - CompositionEntityResponseDto<NicDto> responseDto = new CompositionEntityResponseDto<>(); - new MapCompositionEntityResponseToDto<>(new MapNicToNicDto(), NicDto.class) - .doMapping(response, responseDto); - return Response.ok(responseDto).build(); - } + @Override + public Response list(String vspId, String versionId, String componentId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + Collection<NicEntity> nics = nicManager.listNics(vspId, vspVersion, componentId); + MapNicEntityToNicDto mapper = new MapNicEntityToNicDto(); + GenericCollectionWrapper<NicDto> results = new GenericCollectionWrapper<>(); + for (NicEntity nic : nics) { + results.add(mapper.applyMapping(nic, NicDto.class)); + } + return Response.ok(results).build(); + } - @Override - public Response delete(String vspId, String versionId, String componentId, String nicId, - String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - nicManager.deleteNic(vspId, vspVersion, componentId, nicId); - return Response.ok().build(); - } + @Override + public Response create(NicRequestDto request, String vspId, String versionId, String componentId, String user) { + NicEntity nic = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class); + nic.setVspId(vspId); + nic.setVersion(new Version(versionId)); + nic.setComponentId(componentId); + componentManager.validateComponentExistence(vspId, nic.getVersion(), componentId); + NicEntity createdNic = nicManager.createNic(nic); + MapNicEntityToNicCreationResponseDto mapping = new MapNicEntityToNicCreationResponseDto(); + NicCreationResponseDto createdNicDto = mapping.applyMapping(createdNic, NicCreationResponseDto.class); + return Response.ok(createdNic != null ? createdNicDto : null).build(); + } - @Override - public Response update(NicRequestDto request, String vspId, String versionId, String componentId, - String nicId, - String user) { - NicEntity nicEntity = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class); - nicEntity.setVspId(vspId); - nicEntity.setVersion(new Version(versionId)); - nicEntity.setComponentId(componentId); - nicEntity.setId(nicId); + @Override + public Response get(String vspId, String versionId, String componentId, String nicId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + CompositionEntityResponse<Nic> response = nicManager.getNic(vspId, vspVersion, componentId, nicId); + CompositionEntityResponseDto<NicDto> responseDto = new CompositionEntityResponseDto<>(); + new MapCompositionEntityResponseToDto<>(new MapNicToNicDto(), NicDto.class).doMapping(response, responseDto); + return Response.ok(responseDto).build(); + } - componentManager.validateComponentExistence(vspId, nicEntity.getVersion(), componentId); - CompositionEntityValidationData validationData = - nicManager.updateNic(nicEntity); - return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) - ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto() - .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : - Response.ok().build(); - } + @Override + public Response delete(String vspId, String versionId, String componentId, String nicId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + nicManager.deleteNic(vspId, vspVersion, componentId, nicId); + return Response.ok().build(); + } - @Override - public Response getQuestionnaire(String vspId, String versionId, String componentId, String nicId, - String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - QuestionnaireResponse questionnaireResponse = - nicManager.getNicQuestionnaire(vspId, vspVersion, componentId, nicId); + @Override + public Response update(NicRequestDto request, String vspId, String versionId, String componentId, String nicId, String user) { + NicEntity nicEntity = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class); + nicEntity.setVspId(vspId); + nicEntity.setVersion(new Version(versionId)); + nicEntity.setComponentId(componentId); + nicEntity.setId(nicId); + componentManager.validateComponentExistence(vspId, nicEntity.getVersion(), componentId); + CompositionEntityValidationData validationData = nicManager.updateNic(nicEntity); + return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapCompositionEntityValidationDataToDto().applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() + : Response.ok().build(); + } - QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() - .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); - return Response.ok(result).build(); - } + @Override + public Response getQuestionnaire(String vspId, String versionId, String componentId, String nicId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + QuestionnaireResponse questionnaireResponse = nicManager.getNicQuestionnaire(vspId, vspVersion, componentId, nicId); + QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + return Response.ok(result).build(); + } - @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, - String componentId, - String nicId, String user) { - Version vspVersion = new Version(versionId); - componentManager.validateComponentExistence(vspId, vspVersion, componentId); - nicManager - .updateNicQuestionnaire(vspId, vspVersion, componentId, nicId, questionnaireData); - return Response.ok().build(); - } + @Override + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String componentId, String nicId, String user) { + Version vspVersion = new Version(versionId); + componentManager.validateComponentExistence(vspId, vspVersion, componentId); + nicManager.updateNicQuestionnaire(vspId, vspVersion, componentId, nicId, questionnaireData); + return Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateException.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateException.java index a7e65a7e6f..1e20d1ced7 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateException.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateException.java @@ -19,9 +19,9 @@ */ package org.openecomp.sdcrests.vsp.rest.services; -public class OrchestrationTemplateCandidateException extends Exception{ +public class OrchestrationTemplateCandidateException extends Exception { - public OrchestrationTemplateCandidateException(String message, Throwable t){ + public OrchestrationTemplateCandidateException(String message, Throwable t) { super(message, t); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java index b393153ece..48ad75d09c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java @@ -18,7 +18,6 @@ * Modifications copyright (c) 2019 Nokia * ================================================================================ */ - package org.openecomp.sdcrests.vsp.rest.services; import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters; @@ -74,56 +73,47 @@ import org.springframework.stereotype.Service; @Service("orchestrationTemplateCandidate") @Scope(value = "prototype") public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplateCandidate { - private static final Logger LOGGER = - LoggerFactory.getLogger(OrchestrationTemplateCandidateImpl.class); - private final OrchestrationTemplateCandidateManager candidateManager; - - private final VendorSoftwareProductManager vendorSoftwareProductManager; - private final ActivityLogManager activityLogManager; - - - public OrchestrationTemplateCandidateImpl() { - this.candidateManager = OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface(); - this.vendorSoftwareProductManager = VspManagerFactory.getInstance().createInterface(); - this.activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); - } - - // Constructor used in test to avoid mock static - public OrchestrationTemplateCandidateImpl( - OrchestrationTemplateCandidateManager candidateManager, - VendorSoftwareProductManager vendorSoftwareProductManager, - ActivityLogManager activityLogManager) { - this.candidateManager = candidateManager; - this.vendorSoftwareProductManager = vendorSoftwareProductManager; - this.activityLogManager = activityLogManager; - } - - @Override - public Response upload(final String vspId, final String versionId, - final Attachment fileToUpload, final String user) { - final byte[] fileToUploadBytes = fileToUpload.getObject(byte[].class); - final DataHandler dataHandler = fileToUpload.getDataHandler(); - final String filename = ValidationUtils.sanitizeInputString(dataHandler.getName()); - - final OnboardingPackageProcessor onboardingPackageProcessor = new OnboardingPackageProcessor(filename, fileToUploadBytes); - if (onboardingPackageProcessor.hasErrors()) { - final UploadFileResponseDto uploadFileResponseDto = - buildUploadResponseWithError(onboardingPackageProcessor.getErrorMessages().toArray(new ErrorMessage[0])); - return Response.status(Status.NOT_ACCEPTABLE).entity(uploadFileResponseDto).build(); - } - final OnboardPackageInfo onboardPackageInfo = onboardingPackageProcessor.getOnboardPackageInfo().orElse(null); + private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateCandidateImpl.class); + private final OrchestrationTemplateCandidateManager candidateManager; + private final VendorSoftwareProductManager vendorSoftwareProductManager; + private final ActivityLogManager activityLogManager; - if (onboardPackageInfo == null) { - final UploadFileResponseDto uploadFileResponseDto = buildUploadResponseWithError( - new ErrorMessage(ErrorLevel.ERROR, Messages.PACKAGE_PROCESS_ERROR.formatMessage(filename))); - return Response.ok(uploadFileResponseDto).build(); + public OrchestrationTemplateCandidateImpl() { + this.candidateManager = OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface(); + this.vendorSoftwareProductManager = VspManagerFactory.getInstance().createInterface(); + this.activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); } - final VspDetails vspDetails = new VspDetails(ValidationUtils.sanitizeInputString(vspId), - new Version(ValidationUtils.sanitizeInputString(versionId))); - return processOnboardPackage(onboardPackageInfo, vspDetails); - } + // Constructor used in test to avoid mock static + public OrchestrationTemplateCandidateImpl(OrchestrationTemplateCandidateManager candidateManager, + VendorSoftwareProductManager vendorSoftwareProductManager, ActivityLogManager activityLogManager) { + this.candidateManager = candidateManager; + this.vendorSoftwareProductManager = vendorSoftwareProductManager; + this.activityLogManager = activityLogManager; + } + + @Override + public Response upload(final String vspId, final String versionId, final Attachment fileToUpload, final String user) { + final byte[] fileToUploadBytes = fileToUpload.getObject(byte[].class); + final DataHandler dataHandler = fileToUpload.getDataHandler(); + final String filename = ValidationUtils.sanitizeInputString(dataHandler.getName()); + final OnboardingPackageProcessor onboardingPackageProcessor = new OnboardingPackageProcessor(filename, fileToUploadBytes); + if (onboardingPackageProcessor.hasErrors()) { + final UploadFileResponseDto uploadFileResponseDto = buildUploadResponseWithError( + onboardingPackageProcessor.getErrorMessages().toArray(new ErrorMessage[0])); + return Response.status(Status.NOT_ACCEPTABLE).entity(uploadFileResponseDto).build(); + } + final OnboardPackageInfo onboardPackageInfo = onboardingPackageProcessor.getOnboardPackageInfo().orElse(null); + if (onboardPackageInfo == null) { + final UploadFileResponseDto uploadFileResponseDto = buildUploadResponseWithError( + new ErrorMessage(ErrorLevel.ERROR, Messages.PACKAGE_PROCESS_ERROR.formatMessage(filename))); + return Response.ok(uploadFileResponseDto).build(); + } + final VspDetails vspDetails = new VspDetails(ValidationUtils.sanitizeInputString(vspId), + new Version(ValidationUtils.sanitizeInputString(versionId))); + return processOnboardPackage(onboardPackageInfo, vspDetails); + } private Response processOnboardPackage(final OnboardPackageInfo onboardPackageInfo, final VspDetails vspDetails) { final UploadFileResponse uploadFileResponse = candidateManager.upload(vspDetails, onboardPackageInfo); @@ -132,108 +122,89 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate return Response.ok(uploadFileResponseDto).build(); } - private UploadFileResponseDto buildUploadResponseWithError(final ErrorMessage... errorMessages) { - final UploadFileResponseDto uploadFileResponseDto = new UploadFileResponseDto(); - final Map<String, List<ErrorMessage>> errorMap = new HashMap<>(); - final List<ErrorMessage> errorMessageList = new ArrayList<>(); - Collections.addAll(errorMessageList, errorMessages); - errorMap.put(SdcCommon.UPLOAD_FILE, errorMessageList); - uploadFileResponseDto.setErrors(errorMap); - return uploadFileResponseDto; - } - - @Override - public Response get(String vspId, String versionId, String user) throws IOException { - Optional<Pair<String, byte[]>> zipFile = candidateManager.get(vspId, new Version(versionId)); - String fileName; - if (zipFile.isPresent()) { - fileName = "Candidate." + zipFile.get().getLeft(); - } else { - zipFile = vendorSoftwareProductManager.get(vspId, new Version((versionId))); - - if (!zipFile.isPresent()) { - ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR, - getErrorWithParameters( - Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(), - "")); - LOGGER.error(errorMessage.getMessage()); - return Response.status(Response.Status.NOT_FOUND).build(); - } - fileName = "Processed." + zipFile.get().getLeft(); + private UploadFileResponseDto buildUploadResponseWithError(final ErrorMessage... errorMessages) { + final UploadFileResponseDto uploadFileResponseDto = new UploadFileResponseDto(); + final Map<String, List<ErrorMessage>> errorMap = new HashMap<>(); + final List<ErrorMessage> errorMessageList = new ArrayList<>(); + Collections.addAll(errorMessageList, errorMessages); + errorMap.put(SdcCommon.UPLOAD_FILE, errorMessageList); + uploadFileResponseDto.setErrors(errorMap); + return uploadFileResponseDto; } - Response.ResponseBuilder response = Response.ok(zipFile.get().getRight()); - response.header("Content-Disposition", "attachment; filename=" + fileName); - return response.build(); - } - - @Override - public Response abort(String vspId, String versionId) { - candidateManager.abort(vspId, new Version(versionId)); - return Response.ok().build(); - } - - @Override - public Response process(String vspId, String versionId, String user) { - - Version version = new Version(versionId); - OrchestrationTemplateActionResponse response = candidateManager.process(vspId, version); - - activityLogManager.logActivity(new ActivityLogEntity(vspId, version, - ActivityType.Upload_Network_Package, user, true, "", "")); - - OrchestrationTemplateActionResponseDto responseDto = copyOrchestrationTemplateActionResponseToDto(response); - return Response.ok(responseDto).build(); - } - - @Override - public Response updateFilesDataStructure( - String vspId, String versionId, FileDataStructureDto fileDataStructureDto, String user) { - - FilesDataStructure fileDataStructure = copyFilesDataStructureDtoToFilesDataStructure(fileDataStructureDto); + @Override + public Response get(String vspId, String versionId, String user) throws IOException { + Optional<Pair<String, byte[]>> zipFile = candidateManager.get(vspId, new Version(versionId)); + String fileName; + if (zipFile.isPresent()) { + fileName = "Candidate." + zipFile.get().getLeft(); + } else { + zipFile = vendorSoftwareProductManager.get(vspId, new Version((versionId))); + if (!zipFile.isPresent()) { + ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR, + getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(), "")); + LOGGER.error(errorMessage.getMessage()); + return Response.status(Response.Status.NOT_FOUND).build(); + } + fileName = "Processed." + zipFile.get().getLeft(); + } + Response.ResponseBuilder response = Response.ok(zipFile.get().getRight()); + response.header("Content-Disposition", "attachment; filename=" + fileName); + return response.build(); + } - ValidationResponse response = candidateManager - .updateFilesDataStructure(vspId, new Version(versionId), fileDataStructure); + @Override + public Response abort(String vspId, String versionId) { + candidateManager.abort(vspId, new Version(versionId)); + return Response.ok().build(); + } - if (!response.isValid()) { - return Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapValidationResponseToDto() - .applyMapping(response, ValidationResponseDto.class)).build(); + @Override + public Response process(String vspId, String versionId, String user) { + Version version = new Version(versionId); + OrchestrationTemplateActionResponse response = candidateManager.process(vspId, version); + activityLogManager.logActivity(new ActivityLogEntity(vspId, version, ActivityType.Upload_Network_Package, user, true, "", "")); + OrchestrationTemplateActionResponseDto responseDto = copyOrchestrationTemplateActionResponseToDto(response); + return Response.ok(responseDto).build(); } - return Response.ok(fileDataStructureDto).build(); - } - - @Override - public Response getFilesDataStructure(String vspId, String versionId, String user) { - Optional<FilesDataStructure> filesDataStructure = - candidateManager.getFilesDataStructure(vspId, new Version(versionId)); - if (!filesDataStructure.isPresent()) { - filesDataStructure = vendorSoftwareProductManager.getOrchestrationTemplateStructure(vspId, - new Version(versionId)); + + @Override + public Response updateFilesDataStructure(String vspId, String versionId, FileDataStructureDto fileDataStructureDto, String user) { + FilesDataStructure fileDataStructure = copyFilesDataStructureDtoToFilesDataStructure(fileDataStructureDto); + ValidationResponse response = candidateManager.updateFilesDataStructure(vspId, new Version(versionId), fileDataStructure); + if (!response.isValid()) { + return Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapValidationResponseToDto().applyMapping(response, ValidationResponseDto.class)).build(); + } + return Response.ok(fileDataStructureDto).build(); } - FileDataStructureDto fileDataStructureDto = - filesDataStructure.map(dataStructure -> new MapFilesDataStructureToDto() - .applyMapping(dataStructure, FileDataStructureDto.class)) + @Override + public Response getFilesDataStructure(String vspId, String versionId, String user) { + Optional<FilesDataStructure> filesDataStructure = candidateManager.getFilesDataStructure(vspId, new Version(versionId)); + if (!filesDataStructure.isPresent()) { + filesDataStructure = vendorSoftwareProductManager.getOrchestrationTemplateStructure(vspId, new Version(versionId)); + } + FileDataStructureDto fileDataStructureDto = filesDataStructure + .map(dataStructure -> new MapFilesDataStructureToDto().applyMapping(dataStructure, FileDataStructureDto.class)) .orElse(new FileDataStructureDto()); - return Response.ok(fileDataStructureDto).build(); - } - - private OrchestrationTemplateActionResponseDto copyOrchestrationTemplateActionResponseToDto(OrchestrationTemplateActionResponse response){ - OrchestrationTemplateActionResponseDto result = new OrchestrationTemplateActionResponseDto(); - result.setErrors(response.getErrors()); - result.setFileNames(response.getFileNames()); - result.setStatus(response.getStatus()); - return result; - } - - private FilesDataStructure copyFilesDataStructureDtoToFilesDataStructure(FileDataStructureDto fileDataStructureDto){ - FilesDataStructure filesDataStructure = new FilesDataStructure(); - filesDataStructure.setArtifacts(fileDataStructureDto.getArtifacts()); - filesDataStructure.setModules(fileDataStructureDto.getModules()); - filesDataStructure.setNested(fileDataStructureDto.getNested()); - filesDataStructure.setUnassigned(fileDataStructureDto.getUnassigned()); - return filesDataStructure; - } + return Response.ok(fileDataStructureDto).build(); + } + + private OrchestrationTemplateActionResponseDto copyOrchestrationTemplateActionResponseToDto(OrchestrationTemplateActionResponse response) { + OrchestrationTemplateActionResponseDto result = new OrchestrationTemplateActionResponseDto(); + result.setErrors(response.getErrors()); + result.setFileNames(response.getFileNames()); + result.setStatus(response.getStatus()); + return result; + } + private FilesDataStructure copyFilesDataStructureDtoToFilesDataStructure(FileDataStructureDto fileDataStructureDto) { + FilesDataStructure filesDataStructure = new FilesDataStructure(); + filesDataStructure.setArtifacts(fileDataStructureDto.getArtifacts()); + filesDataStructure.setModules(fileDataStructureDto.getModules()); + filesDataStructure.setNested(fileDataStructureDto.getNested()); + filesDataStructure.setUnassigned(fileDataStructureDto.getUnassigned()); + return filesDataStructure; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java index 3a03b1f73b..2d6efcda88 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,9 +19,10 @@ * Modifications copyright (c) 2019 Nokia * ================================================================================ */ - package org.openecomp.sdcrests.vsp.rest.services; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; import org.openecomp.sdcrests.vsp.rest.ComponentProcesses; @@ -30,66 +31,60 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; - @Named @Service("processes") @Scope(value = "prototype") public class ProcessesImpl implements Processes { - private final ComponentProcesses componentProcesses; + private final ComponentProcesses componentProcesses; - @Autowired - public ProcessesImpl(ComponentProcesses componentProcesses) { - this.componentProcesses = componentProcesses; - } + @Autowired + public ProcessesImpl(ComponentProcesses componentProcesses) { + this.componentProcesses = componentProcesses; + } - @Override - public Response list(String vspId, String versionId, String user) { - return componentProcesses.list(vspId, versionId, null, user); - } + @Override + public Response list(String vspId, String versionId, String user) { + return componentProcesses.list(vspId, versionId, null, user); + } - @Override - public Response deleteList(String vspId, String versionId, String user) { - return componentProcesses.deleteList(vspId, versionId, null, user); - } + @Override + public Response deleteList(String vspId, String versionId, String user) { + return componentProcesses.deleteList(vspId, versionId, null, user); + } - @Override - public Response create(ProcessRequestDto request, String vspId, String versionId, String user) { - return componentProcesses.create(request, vspId, versionId, null, user); - } + @Override + public Response create(ProcessRequestDto request, String vspId, String versionId, String user) { + return componentProcesses.create(request, vspId, versionId, null, user); + } - @Override - public Response get(String vspId, String versionId, String processId, String user) { - return componentProcesses.get(vspId, versionId, null, processId, user); - } + @Override + public Response get(String vspId, String versionId, String processId, String user) { + return componentProcesses.get(vspId, versionId, null, processId, user); + } - @Override - public Response delete(String vspId, String versionId, String processId, String user) { - return componentProcesses.delete(vspId, versionId, null, processId, user); - } + @Override + public Response delete(String vspId, String versionId, String processId, String user) { + return componentProcesses.delete(vspId, versionId, null, processId, user); + } - @Override - public Response update(ProcessRequestDto request, String vspId, String versionId, - String processId, String user) { - return componentProcesses.update(request, vspId, versionId, null, processId, user); - } + @Override + public Response update(ProcessRequestDto request, String vspId, String versionId, String processId, String user) { + return componentProcesses.update(request, vspId, versionId, null, processId, user); + } - @Override - public Response getUploadedFile(String vspId, String versionId, String processId, String user) { - return componentProcesses.getUploadedFile(vspId, versionId, null, processId, user); - } + @Override + public Response getUploadedFile(String vspId, String versionId, String processId, String user) { + return componentProcesses.getUploadedFile(vspId, versionId, null, processId, user); + } - @Override - public Response deleteUploadedFile(String vspId, String versionId, String processId, - String user) { - return componentProcesses.deleteUploadedFile(vspId, versionId, null, processId, user); - } + @Override + public Response deleteUploadedFile(String vspId, String versionId, String processId, String user) { + return componentProcesses.deleteUploadedFile(vspId, versionId, null, processId, user); + } - @Override - public Response uploadFile(Attachment attachment, String vspId, String versionId, - String processId, String user) { - return componentProcesses.uploadFile(attachment, vspId, versionId, null, processId, user); - } + @Override + public Response uploadFile(Attachment attachment, String vspId, String versionId, String processId, String user) { + return componentProcesses.uploadFile(attachment, vspId, versionId, null, processId, user); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java index 91c1959c86..74d2fde097 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java @@ -13,9 +13,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.services; +import static javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION; +import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; +import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME; +import static org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod.NetworkPackage; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.ITEM_NAME; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.SUBMIT_DESCRIPTION; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_ID; +import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.VERSION_NAME; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import javax.inject.Named; +import javax.ws.rs.core.Response; import org.apache.commons.collections4.MapUtils; import org.openecomp.core.dao.UniqueValueDaoFactory; import org.openecomp.core.util.UniqueValueUtil; @@ -40,7 +63,12 @@ import org.openecomp.sdc.notification.services.NotificationPropagationManager; import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.*; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.errors.CreatePackageForNonFinalVendorSoftwareProductErrorBuilder; import org.openecomp.sdc.vendorsoftwareproduct.errors.OnboardingMethodErrorBuilder; import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageNotFoundErrorBuilder; @@ -59,27 +87,28 @@ import org.openecomp.sdc.versioning.types.NotificationEventTypes; import org.openecomp.sdcrests.item.rest.mapping.MapVersionToDto; import org.openecomp.sdcrests.item.types.ItemCreationDto; import org.openecomp.sdcrests.item.types.VersionDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VendorSoftwareProductAction; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspComputeDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspRequestDto; import org.openecomp.sdcrests.vsp.rest.VendorSoftwareProducts; -import org.openecomp.sdcrests.vsp.rest.mapping.*; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComputeEntityToVspComputeDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapItemToVspDetailsDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapPackageInfoToPackageInfoDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapValidationResponseToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDescriptionDtoToItem; +import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDescriptionDtoToVspDetails; +import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDetailsToDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import javax.inject.Named; -import javax.ws.rs.core.Response; -import java.io.File; -import java.io.IOException; -import java.util.*; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -import static javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION; -import static org.openecomp.sdc.itempermissions.notifications.NotificationConstants.PERMISSION_USER; -import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME; -import static org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod.NetworkPackage; -import static org.openecomp.sdc.versioning.VersioningNotificationConstansts.*; - @Named @Service("vendorSoftwareProducts") @Scope(value = "prototype") @@ -89,28 +118,17 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { private static final String VALIDATION_VSP_USER = "validationOnlyVspUser"; private static final String SUBMIT_ITEM_ACTION = "Submit_Item"; private static final String ATTACHMENT_FILENAME = "attachment; filename="; - private static final String SUBMIT_HEALED_VERSION_ERROR = - "VSP Id %s: Error while submitting version %s created based on Certified version %s for healing purpose."; + private static final String SUBMIT_HEALED_VERSION_ERROR = "VSP Id %s: Error while submitting version %s created based on Certified version %s for healing purpose."; private static final Logger LOGGER = LoggerFactory.getLogger(VendorSoftwareProductsImpl.class); private static final Object VALIDATION_VSP_CACHE_LOCK = new Object(); - private static ItemCreationDto cachedValidationVsp; - - private final AsdcItemManager itemManager = AsdcItemManagerFactory.getInstance() - .createInterface(); - private final PermissionsManager permissionsManager = - PermissionsManagerFactory.getInstance().createInterface(); - private final VersioningManager versioningManager = - VersioningManagerFactory.getInstance().createInterface(); - private final VendorSoftwareProductManager vendorSoftwareProductManager = - VspManagerFactory.getInstance().createInterface(); - private final ActivityLogManager activityLogManager = - ActivityLogManagerFactory.getInstance().createInterface(); - private final NotificationPropagationManager notifier = - NotificationPropagationManagerFactory.getInstance().createInterface(); - private final UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory - .getInstance().createInterface()); - + private final AsdcItemManager itemManager = AsdcItemManagerFactory.getInstance().createInterface(); + private final PermissionsManager permissionsManager = PermissionsManagerFactory.getInstance().createInterface(); + private final VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface(); + private final VendorSoftwareProductManager vendorSoftwareProductManager = VspManagerFactory.getInstance().createInterface(); + private final ActivityLogManager activityLogManager = ActivityLogManagerFactory.getInstance().createInterface(); + private final NotificationPropagationManager notifier = NotificationPropagationManagerFactory.getInstance().createInterface(); + private final UniqueValueUtil uniqueValueUtil = new UniqueValueUtil(UniqueValueDaoFactory.getInstance().createInterface()); @Override public Response createVsp(VspRequestDto vspRequestDto, String user) { @@ -119,74 +137,55 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { } private ItemCreationDto createVspItem(VspRequestDto vspRequestDto, String user) { - OnboardingMethod onboardingMethod = null; - try { onboardingMethod = OnboardingMethod.valueOf(vspRequestDto.getOnboardingMethod()); } catch (IllegalArgumentException e) { LOGGER.error("Error while creating VSP. Message: " + e.getMessage()); throwUnknownOnboardingMethodException(e); } - ItemCreationDto itemCreationDto = null; - if (onboardingMethod == NetworkPackage - || onboardingMethod == OnboardingMethod.Manual) { + if (onboardingMethod == NetworkPackage || onboardingMethod == OnboardingMethod.Manual) { itemCreationDto = createItem(vspRequestDto, user, onboardingMethod); - } else { - throwUnknownOnboardingMethodException( - new IllegalArgumentException("Wrong parameter Onboarding Method")); + throwUnknownOnboardingMethodException(new IllegalArgumentException("Wrong parameter Onboarding Method")); } - return itemCreationDto; } private ItemCreationDto createItem(VspRequestDto vspRequestDto, String user, OnboardingMethod onboardingMethod) { - Item item = new MapVspDescriptionDtoToItem().applyMapping(vspRequestDto, Item.class); item.setType(ItemType.vsp.name()); item.setOwner(user); item.setStatus(ItemStatus.ACTIVE); item.addProperty(VspItemProperty.ONBOARDING_METHOD, onboardingMethod.name()); - uniqueValueUtil.validateUniqueValue(VENDOR_SOFTWARE_PRODUCT_NAME, item.getName()); item = itemManager.create(item); uniqueValueUtil.createUniqueValue(VENDOR_SOFTWARE_PRODUCT_NAME, item.getName()); - Version version = versioningManager.create(item.getId(), new Version(), null); - - VspDetails vspDetails = - new MapVspDescriptionDtoToVspDetails().applyMapping(vspRequestDto, VspDetails.class); + VspDetails vspDetails = new MapVspDescriptionDtoToVspDetails().applyMapping(vspRequestDto, VspDetails.class); vspDetails.setId(item.getId()); vspDetails.setVersion(version); vspDetails.setOnboardingMethod(vspRequestDto.getOnboardingMethod()); - vendorSoftwareProductManager.createVsp(vspDetails); versioningManager.publish(item.getId(), version, "Initial vsp:" + vspDetails.getName()); ItemCreationDto itemCreationDto = new ItemCreationDto(); itemCreationDto.setItemId(item.getId()); itemCreationDto.setVersion(new MapVersionToDto().applyMapping(version, VersionDto.class)); - activityLogManager.logActivity(new ActivityLogEntity(vspDetails.getId(), version, - ActivityType.Create, user, true, "", "")); + activityLogManager.logActivity(new ActivityLogEntity(vspDetails.getId(), version, ActivityType.Create, user, true, "", "")); return itemCreationDto; } private void throwUnknownOnboardingMethodException(IllegalArgumentException e) { - ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder - .getInvalidOnboardingMethodErrorBuilder(); + ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder.getInvalidOnboardingMethodErrorBuilder(); throw new CoreException(onboardingMethodUpdateErrorCode, e); } @Override public Response listVsps(String versionStatus, String itemStatus, String user) { - GenericCollectionWrapper<VspDetailsDto> results = new GenericCollectionWrapper<>(); MapItemToVspDetailsDto mapper = new MapItemToVspDetailsDto(); - - getVspList(versionStatus, itemStatus, user) - .forEach(vspItem -> results.add(mapper.applyMapping(vspItem, VspDetailsDto.class))); - + getVspList(versionStatus, itemStatus, user).forEach(vspItem -> results.add(mapper.applyMapping(vspItem, VspDetailsDto.class))); return Response.ok(results).build(); } @@ -194,23 +193,18 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { public Response getVsp(String vspId, String versionId, String user) { Version version = versioningManager.get(vspId, new Version(versionId)); VspDetails vspDetails = vendorSoftwareProductManager.getVsp(vspId, version); - try { - HealingManagerFactory.getInstance().createInterface() - .healItemVersion(vspId, version, ItemType.vsp, false) - .ifPresent(healedVersion -> { - vspDetails.setVersion(healedVersion); - if (version.getStatus() == VersionStatus.Certified) { - submitHealedVersion(vspDetails, versionId, user); - } - }); + HealingManagerFactory.getInstance().createInterface().healItemVersion(vspId, version, ItemType.vsp, false).ifPresent(healedVersion -> { + vspDetails.setVersion(healedVersion); + if (version.getStatus() == VersionStatus.Certified) { + submitHealedVersion(vspDetails, versionId, user); + } + }); } catch (Exception e) { LOGGER.error(String.format("Error while auto healing VSP with Id %s and version %s", vspId, versionId), e); } - VspDetailsDto vspDetailsDto = new MapVspDetailsToDto().applyMapping(vspDetails, VspDetailsDto.class); addNetworkPackageInfo(vspId, vspDetails.getVersion(), vspDetailsDto); - return Response.ok(vspDetailsDto).build(); } @@ -220,88 +214,63 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { // sync vlm if not exists on user space versioningManager.get(vspDetails.getVendorId(), vspDetails.getVlmVersion()); } - - submit(vspDetails.getId(), vspDetails.getVersion(), "Submit healed Vsp", user) - .ifPresent(validationResponse -> { - throw new IllegalStateException("Certified vsp after healing failed on validation"); - }); + submit(vspDetails.getId(), vspDetails.getVersion(), "Submit healed Vsp", user).ifPresent(validationResponse -> { + throw new IllegalStateException("Certified vsp after healing failed on validation"); + }); vendorSoftwareProductManager.createPackage(vspDetails.getId(), vspDetails.getVersion()); } catch (Exception ex) { - LOGGER.error(String.format(SUBMIT_HEALED_VERSION_ERROR, vspDetails.getId(), vspDetails.getVersion().getId(), - baseVersionId), ex); + LOGGER.error(String.format(SUBMIT_HEALED_VERSION_ERROR, vspDetails.getId(), vspDetails.getVersion().getId(), baseVersionId), ex); } } @Override - public Response updateVsp(String vspId, String versionId, VspDescriptionDto vspDescriptionDto, - String user) { - VspDetails vspDetails = - new MapVspDescriptionDtoToVspDetails().applyMapping(vspDescriptionDto, VspDetails.class); + public Response updateVsp(String vspId, String versionId, VspDescriptionDto vspDescriptionDto, String user) { + VspDetails vspDetails = new MapVspDescriptionDtoToVspDetails().applyMapping(vspDescriptionDto, VspDetails.class); vspDetails.setId(vspId); vspDetails.setVersion(new Version(versionId)); - vendorSoftwareProductManager.updateVsp(vspDetails); - - updateVspItem(vspId,vspDescriptionDto); - + updateVspItem(vspId, vspDescriptionDto); return Response.ok().build(); } @Override public Response deleteVsp(String vspId, String user) { Item vsp = itemManager.get(vspId); - if (!vsp.getType().equals(ItemType.vsp.name())) { - throw new CoreException((new ErrorCode.ErrorCodeBuilder() - .withMessage(String.format("Vsp with id %s does not exist.", - vspId)).build())); + throw new CoreException((new ErrorCode.ErrorCodeBuilder().withMessage(String.format("Vsp with id %s does not exist.", vspId)).build())); } - Integer certifiedVersionsCounter = vsp.getVersionStatusCounters().get(VersionStatus.Certified); if (Objects.isNull(certifiedVersionsCounter) || certifiedVersionsCounter == 0) { - versioningManager.list(vspId) - .forEach(version -> vendorSoftwareProductManager.deleteVsp(vspId, version)); + versioningManager.list(vspId).forEach(version -> vendorSoftwareProductManager.deleteVsp(vspId, version)); itemManager.delete(vsp); permissionsManager.deleteItemPermissions(vspId); uniqueValueUtil.deleteUniqueValue(VENDOR_SOFTWARE_PRODUCT_NAME, vsp.getName()); - notifyUsers(vspId, vsp.getName(), null, null, user, - NotificationEventTypes.DELETE); - + notifyUsers(vspId, vsp.getName(), null, null, user, NotificationEventTypes.DELETE); return Response.ok().build(); } else { - return Response.status(Response.Status.FORBIDDEN) - .entity(new Exception(Messages.DELETE_VSP_ERROR.getErrorMessage())).build(); + return Response.status(Response.Status.FORBIDDEN).entity(new Exception(Messages.DELETE_VSP_ERROR.getErrorMessage())).build(); } } @Override - public Response actOnVendorSoftwareProduct(VersionSoftwareProductActionRequestDto request, - String vspId, String versionId, - String user) throws IOException { + public Response actOnVendorSoftwareProduct(VersionSoftwareProductActionRequestDto request, String vspId, String versionId, String user) + throws IOException { Version version = new Version(versionId); - if (request.getAction() == VendorSoftwareProductAction.Submit) { if (!permissionsManager.isAllowed(vspId, user, SUBMIT_ITEM_ACTION)) { - return Response.status(Response.Status.FORBIDDEN) - .entity(new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build(); + return Response.status(Response.Status.FORBIDDEN).entity(new Exception(Messages.PERMISSIONS_ERROR.getErrorMessage())).build(); } - String message = request.getSubmitRequest() == null ? "Submit" - : request.getSubmitRequest().getMessage(); + String message = request.getSubmitRequest() == null ? "Submit" : request.getSubmitRequest().getMessage(); Optional<ValidationResponse> validationResponse = submit(vspId, version, message, user); - if (validationResponse.isPresent()) { ValidationResponseDto validationResponseDto = new MapValidationResponseToDto() - .applyMapping(validationResponse.get(), ValidationResponseDto.class); - return Response.status(Response.Status.EXPECTATION_FAILED).entity(validationResponseDto) - .build(); + .applyMapping(validationResponse.get(), ValidationResponseDto.class); + return Response.status(Response.Status.EXPECTATION_FAILED).entity(validationResponseDto).build(); } - notifyUsers(vspId, null, version, message, user, NotificationEventTypes.SUBMIT); - } else if (request.getAction() == VendorSoftwareProductAction.Create_Package) { return createPackage(vspId, version); } - return Response.ok().build(); } @@ -312,35 +281,24 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { } private ItemCreationDto retrieveValidationVsp() { - synchronized (VALIDATION_VSP_CACHE_LOCK) { - if (cachedValidationVsp != null) { return cachedValidationVsp; } - VspRequestDto validationVspRequest = new VspRequestDto(); validationVspRequest.setOnboardingMethod(NetworkPackage.toString()); validationVspRequest.setName(VALIDATION_VSP_NAME); - try { - cachedValidationVsp = createVspItem(validationVspRequest, VALIDATION_VSP_USER); return cachedValidationVsp; - } catch (CoreException vspCreateException) { LOGGER.debug("Failed to create validation VSP", vspCreateException); - Predicate<Item> validationVspFilter = item -> ItemType.vsp.name().equals(item.getType()) - && VALIDATION_VSP_NAME.equals(item.getName()); - String validationVspId = itemManager.list(validationVspFilter).stream().findFirst() - .orElseThrow(() -> new IllegalStateException( - "Vsp with name " + VALIDATION_VSP_NAME + - " does not exist even though the name exists according to " + - "unique value util")) - .getId(); - + Predicate<Item> validationVspFilter = item -> ItemType.vsp.name().equals(item.getType()) && VALIDATION_VSP_NAME + .equals(item.getName()); + String validationVspId = itemManager.list(validationVspFilter).stream().findFirst().orElseThrow(() -> new IllegalStateException( + "Vsp with name " + VALIDATION_VSP_NAME + " does not exist even though the name exists according to " + "unique value util")) + .getId(); Version validationVspVersion = versioningManager.list(validationVspId).iterator().next(); - cachedValidationVsp = new ItemCreationDto(); cachedValidationVsp.setItemId(validationVspId); cachedValidationVsp.setVersion(new MapVersionToDto().applyMapping(validationVspVersion, VersionDto.class)); @@ -351,9 +309,7 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { @Override public Response getOrchestrationTemplate(String vspId, String versionId, String user) { - byte[] orchestrationTemplateFile = - vendorSoftwareProductManager.getOrchestrationTemplateFile(vspId, new Version(versionId)); - + byte[] orchestrationTemplateFile = vendorSoftwareProductManager.getOrchestrationTemplateFile(vspId, new Version(versionId)); if (orchestrationTemplateFile == null || orchestrationTemplateFile.length == 0) { return Response.status(Response.Status.NOT_FOUND).build(); } @@ -364,21 +320,12 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { @Override public Response listPackages(String status, String category, String subCategory, String user) { - - List<String> vspsIds = - getVspList(null, status != null ? ItemStatus.valueOf(status).name() : null, user) - .stream().map(Item::getId).collect(Collectors.toList()); - - List<PackageInfo> packageInfoList = - vendorSoftwareProductManager.listPackages(category, subCategory); - - packageInfoList = packageInfoList.stream(). - filter(packageInfo -> vspsIds.contains(packageInfo.getVspId())) - .collect(Collectors.toList()); - + List<String> vspsIds = getVspList(null, status != null ? ItemStatus.valueOf(status).name() : null, user).stream().map(Item::getId) + .collect(Collectors.toList()); + List<PackageInfo> packageInfoList = vendorSoftwareProductManager.listPackages(category, subCategory); + packageInfoList = packageInfoList.stream().filter(packageInfo -> vspsIds.contains(packageInfo.getVspId())).collect(Collectors.toList()); GenericCollectionWrapper<PackageInfoDto> results = new GenericCollectionWrapper<>(); MapPackageInfoToPackageInfoDto mapper = new MapPackageInfoToPackageInfoDto(); - if (packageInfoList != null) { for (PackageInfo packageInfo : packageInfoList) { results.add(mapper.applyMapping(packageInfo, PackageInfoDto.class)); @@ -393,90 +340,71 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { Version version; if (versionName == null) { version = versions.stream().filter(ver -> VersionStatus.Certified == ver.getStatus()) - .max(Comparator.comparingDouble(o -> Double.parseDouble(o.getName()))) - .orElseThrow(() -> new CoreException(new PackageNotFoundErrorBuilder(vspId).build())); + .max(Comparator.comparingDouble(o -> Double.parseDouble(o.getName()))) + .orElseThrow(() -> new CoreException(new PackageNotFoundErrorBuilder(vspId).build())); } else { - version = versions.stream().filter(ver -> versionName.equals(ver.getName())) - .findFirst() - .orElseThrow(() -> new CoreException(new PackageNotFoundErrorBuilder(vspId).build())); - + version = versions.stream().filter(ver -> versionName.equals(ver.getName())).findFirst() + .orElseThrow(() -> new CoreException(new PackageNotFoundErrorBuilder(vspId).build())); if (version.getStatus() != VersionStatus.Certified) { throw new CoreException(new RequestedVersionInvalidErrorBuilder().build()); } } - File zipFile = vendorSoftwareProductManager.getTranslatedFile(vspId, version); - Response.ResponseBuilder response = Response.ok(zipFile); if (zipFile == null) { return Response.status(Response.Status.NOT_FOUND).build(); } response.header(CONTENT_DISPOSITION, ATTACHMENT_FILENAME + zipFile.getName()); - return response.build(); } @Override public Response getQuestionnaire(String vspId, String versionId, String user) { - QuestionnaireResponse questionnaireResponse = - vendorSoftwareProductManager.getVspQuestionnaire(vspId, new Version(versionId)); - + QuestionnaireResponse questionnaireResponse = vendorSoftwareProductManager.getVspQuestionnaire(vspId, new Version(versionId)); if (questionnaireResponse.getErrorMessage() != null) { - return Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapQuestionnaireResponseToQuestionnaireResponseDto() - .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class)).build(); + return Response.status(Response.Status.EXPECTATION_FAILED) + .entity(new MapQuestionnaireResponseToQuestionnaireResponseDto().applyMapping(questionnaireResponse, QuestionnaireResponseDto.class)) + .build(); } - QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() - .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); return Response.ok(result).build(); } @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String - versionId, String user) { - vendorSoftwareProductManager - .updateVspQuestionnaire(vspId, new Version(versionId), questionnaireData); + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String user) { + vendorSoftwareProductManager.updateVspQuestionnaire(vspId, new Version(versionId), questionnaireData); return Response.ok().build(); } @Override public Response heal(String vspId, String versionId, String user) { - HealingManagerFactory.getInstance().createInterface() - .healItemVersion(vspId, new Version(versionId), ItemType.vsp, true); + HealingManagerFactory.getInstance().createInterface().healItemVersion(vspId, new Version(versionId), ItemType.vsp, true); return Response.ok().build(); } @Override public Response getVspInformationArtifact(String vspId, String versionId, String user) { - File textInformationArtifact = - vendorSoftwareProductManager.getInformationArtifact(vspId, new Version(versionId)); - + File textInformationArtifact = vendorSoftwareProductManager.getInformationArtifact(vspId, new Version(versionId)); Response.ResponseBuilder response = Response.ok(textInformationArtifact); if (textInformationArtifact == null) { return Response.status(Response.Status.NOT_FOUND).build(); } - response - .header(CONTENT_DISPOSITION, ATTACHMENT_FILENAME + textInformationArtifact.getName()); + response.header(CONTENT_DISPOSITION, ATTACHMENT_FILENAME + textInformationArtifact.getName()); return response.build(); } @Override public Response listComputes(String vspId, String version, String user) { - - Collection<ComputeEntity> computes = - vendorSoftwareProductManager.getComputeByVsp(vspId, new Version(version)); - + Collection<ComputeEntity> computes = vendorSoftwareProductManager.getComputeByVsp(vspId, new Version(version)); MapComputeEntityToVspComputeDto mapper = new MapComputeEntityToVspComputeDto(); GenericCollectionWrapper<VspComputeDto> results = new GenericCollectionWrapper<>(); for (ComputeEntity compute : computes) { results.add(mapper.applyMapping(compute, VspComputeDto.class)); } - return Response.ok(results).build(); } - private void updateVspItem(String vspId, VspDescriptionDto vspDescriptionDto) { Item retrievedItem = itemManager.get(vspId); Item item = new MapVspDescriptionDtoToItem().applyMapping(vspDescriptionDto, Item.class); @@ -487,52 +415,37 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { item.setVersionStatusCounters(retrievedItem.getVersionStatusCounters()); item.setCreationTime(retrievedItem.getCreationTime()); item.setModificationTime(new Date()); - item.addProperty(VspItemProperty.ONBOARDING_METHOD, - retrievedItem.getProperties().get(VspItemProperty.ONBOARDING_METHOD)); - + item.addProperty(VspItemProperty.ONBOARDING_METHOD, retrievedItem.getProperties().get(VspItemProperty.ONBOARDING_METHOD)); itemManager.update(item); } - private Optional<ValidationResponse> submit(String vspId, Version version, String message, - String user) throws IOException { - + private Optional<ValidationResponse> submit(String vspId, Version version, String message, String user) throws IOException { VspDetails vspDetails = vendorSoftwareProductManager.getVsp(vspId, version); if (vspDetails.getVlmVersion() != null) { vspDetails.setVlmVersion(versioningManager.get(vspDetails.getVendorId(), vspDetails.getVlmVersion())); } ValidationResponse validationResponse = vendorSoftwareProductManager.validate(vspDetails); - Map<String, List<ErrorMessage>> compilationErrors = - vendorSoftwareProductManager.compile(vspId, version); + Map<String, List<ErrorMessage>> compilationErrors = vendorSoftwareProductManager.compile(vspId, version); if (!validationResponse.isValid() || MapUtils.isNotEmpty(compilationErrors)) { - activityLogManager.logActivity( - new ActivityLogEntity(vspId, version, ActivityType.Submit, user, false, - "Failed on validation before submit", "")); + activityLogManager + .logActivity(new ActivityLogEntity(vspId, version, ActivityType.Submit, user, false, "Failed on validation before submit", "")); return Optional.of(validationResponse); } - versioningManager.submit(vspId, version, message); - activityLogManager.logActivity( - new ActivityLogEntity(vspId, version, ActivityType.Submit, user, true, "", message)); + activityLogManager.logActivity(new ActivityLogEntity(vspId, version, ActivityType.Submit, user, true, "", message)); return Optional.empty(); } - private void notifyUsers(String itemId, String itemName, Version version, String message, - String userName, NotificationEventTypes eventType) { + private void notifyUsers(String itemId, String itemName, Version version, String message, String userName, NotificationEventTypes eventType) { Map<String, Object> eventProperties = new HashMap<>(); - eventProperties - .put(ITEM_NAME, itemName == null ? itemManager.get(itemId).getName() : itemName); + eventProperties.put(ITEM_NAME, itemName == null ? itemManager.get(itemId).getName() : itemName); eventProperties.put(ITEM_ID, itemId); - if (version != null) { - eventProperties.put(VERSION_NAME, version.getName() == null - ? versioningManager.get(itemId, version).getName() - : version.getName()); + eventProperties.put(VERSION_NAME, version.getName() == null ? versioningManager.get(itemId, version).getName() : version.getName()); eventProperties.put(VERSION_ID, version.getId()); } - eventProperties.put(SUBMIT_DESCRIPTION, message); eventProperties.put(PERMISSION_USER, userName); - Event syncEvent = new SyncEvent(eventType.getEventName(), itemId, eventProperties, itemId); try { notifier.notifySubscribers(syncEvent, userName); @@ -544,91 +457,68 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { private Response createPackage(String vspId, Version version) throws IOException { Version retrievedVersion = versioningManager.get(vspId, version); if (retrievedVersion.getStatus() != VersionStatus.Certified) { - throw new CoreException( - new CreatePackageForNonFinalVendorSoftwareProductErrorBuilder(vspId, version) - .build()); + throw new CoreException(new CreatePackageForNonFinalVendorSoftwareProductErrorBuilder(vspId, version).build()); } - PackageInfo packageInfo = - vendorSoftwareProductManager.createPackage(vspId, retrievedVersion); - return Response.ok(packageInfo == null - ? null - : new MapPackageInfoToPackageInfoDto().applyMapping(packageInfo, PackageInfoDto.class)) - .build(); + PackageInfo packageInfo = vendorSoftwareProductManager.createPackage(vspId, retrievedVersion); + return Response.ok(packageInfo == null ? null : new MapPackageInfoToPackageInfoDto().applyMapping(packageInfo, PackageInfoDto.class)).build(); } - private void addNetworkPackageInfo(String vspId, Version version, VspDetailsDto vspDetailsDto) { - Optional<OrchestrationTemplateCandidateData> candidateInfo = - OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface() + private void addNetworkPackageInfo(String vspId, Version version, VspDetailsDto vspDetailsDto) { + Optional<OrchestrationTemplateCandidateData> candidateInfo = OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface() .getInfo(vspId, version); - if (candidateInfo.isPresent()) { - if (candidateInfo.get().getValidationDataStructure() != null) { - vspDetailsDto.setValidationData(candidateInfo.get().getValidationDataStructure()); - } - vspDetailsDto.setNetworkPackageName(candidateInfo.get().getFileName()); - vspDetailsDto.setCandidateOnboardingOrigin(candidateInfo.get().getFileSuffix()); - } else { - OrchestrationTemplateEntity orchestrationTemplateInfo = - vendorSoftwareProductManager.getOrchestrationTemplateInfo(vspId, version); - if (Objects.nonNull(orchestrationTemplateInfo) && Objects.nonNull(orchestrationTemplateInfo - .getFileSuffix())) { - if (orchestrationTemplateInfo.getValidationDataStructure() != null) { - vspDetailsDto.setValidationData(orchestrationTemplateInfo.getValidationDataStructure()); + if (candidateInfo.isPresent()) { + if (candidateInfo.get().getValidationDataStructure() != null) { + vspDetailsDto.setValidationData(candidateInfo.get().getValidationDataStructure()); + } + vspDetailsDto.setNetworkPackageName(candidateInfo.get().getFileName()); + vspDetailsDto.setCandidateOnboardingOrigin(candidateInfo.get().getFileSuffix()); + } else { + OrchestrationTemplateEntity orchestrationTemplateInfo = vendorSoftwareProductManager.getOrchestrationTemplateInfo(vspId, version); + if (Objects.nonNull(orchestrationTemplateInfo) && Objects.nonNull(orchestrationTemplateInfo.getFileSuffix())) { + if (orchestrationTemplateInfo.getValidationDataStructure() != null) { + vspDetailsDto.setValidationData(orchestrationTemplateInfo.getValidationDataStructure()); + } + vspDetailsDto.setNetworkPackageName(orchestrationTemplateInfo.getFileName()); + vspDetailsDto.setOnboardingOrigin(orchestrationTemplateInfo.getFileSuffix()); + } } - vspDetailsDto.setNetworkPackageName(orchestrationTemplateInfo.getFileName()); - vspDetailsDto.setOnboardingOrigin(orchestrationTemplateInfo.getFileSuffix()); - } } - } - - private boolean userHasPermission(String itemId, String userId) { - return permissionsManager.getUserItemPermission(itemId, userId) - .map(permission -> permission - .matches(PermissionTypes.Contributor.name() + "|" + PermissionTypes.Owner.name())) - .orElse(false); - } - - private Predicate<Item> createItemPredicate(String versionStatus, - String itemStatus, - String user) { - Predicate<Item> itemPredicate = item -> ItemType.vsp.name().equals(item.getType()); + private boolean userHasPermission(String itemId, String userId) { + return permissionsManager.getUserItemPermission(itemId, userId) + .map(permission -> permission.matches(PermissionTypes.Contributor.name() + "|" + PermissionTypes.Owner.name())).orElse(false); + } + + private Predicate<Item> createItemPredicate(String versionStatus, String itemStatus, String user) { + Predicate<Item> itemPredicate = item -> ItemType.vsp.name().equals(item.getType()); if (ItemStatus.ARCHIVED.name().equals(itemStatus)) { itemPredicate = itemPredicate.and(item -> ItemStatus.ARCHIVED.equals(item.getStatus())); } else { itemPredicate = itemPredicate.and(item -> ItemStatus.ACTIVE.equals(item.getStatus())); - if (VersionStatus.Certified.name().equals(versionStatus)) { - itemPredicate = itemPredicate - .and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Certified)); - + itemPredicate = itemPredicate.and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Certified)); } else if (VersionStatus.Draft.name().equals(versionStatus)) { - itemPredicate = itemPredicate.and( - item -> item.getVersionStatusCounters().containsKey(VersionStatus.Draft) - && userHasPermission(item.getId(), user)); + itemPredicate = itemPredicate + .and(item -> item.getVersionStatusCounters().containsKey(VersionStatus.Draft) && userHasPermission(item.getId(), user)); } } return itemPredicate; } private List<Item> getVspList(String versionStatus, String itemStatus, String user) { - Predicate<Item> itemPredicate = createItemPredicate(versionStatus, itemStatus, user); - - return itemManager.list(itemPredicate).stream() - .sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())). - collect(Collectors.toList()); + return itemManager.list(itemPredicate).stream().sorted((o1, o2) -> o2.getModificationTime().compareTo(o1.getModificationTime())) + .collect(Collectors.toList()); } private class SyncEvent implements Event { private final String eventType; - private final String originatorId; private final Map<String, Object> attributes; private final String entityId; - SyncEvent(String eventType, String originatorId, - Map<String, Object> attributes, String entityId) { + SyncEvent(String eventType, String originatorId, Map<String, Object> attributes, String entityId) { this.eventType = eventType; this.originatorId = originatorId; this.attributes = attributes; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VspItemProperty.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VspItemProperty.java index c958ea7c79..87ac7d8fd2 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VspItemProperty.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VspItemProperty.java @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.services; public final class VspItemProperty { - public static final String VENDOR_ID = "vendorId"; - public static final String VENDOR_NAME = "vendorName"; - public static final String ONBOARDING_METHOD = "onboardingMethod"; - private VspItemProperty() { + public static final String VENDOR_ID = "vendorId"; + public static final String VENDOR_NAME = "vendorName"; + public static final String ONBOARDING_METHOD = "onboardingMethod"; - } + private VspItemProperty() { + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VspUniqueTypeProvider.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VspUniqueTypeProvider.java index cb7c136969..b06f4cc383 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VspUniqueTypeProvider.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VspUniqueTypeProvider.java @@ -15,20 +15,18 @@ */ package org.openecomp.sdcrests.vsp.rest.services; -import org.openecomp.sdcrests.uniquevalue.types.UniqueTypesProvider; +import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME; import java.util.Collections; import java.util.Map; - -import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME; +import org.openecomp.sdcrests.uniquevalue.types.UniqueTypesProvider; public class VspUniqueTypeProvider implements UniqueTypesProvider { - private static final Map<String, String> uniqueTypes = - Collections.singletonMap("VspName", VENDOR_SOFTWARE_PRODUCT_NAME); + private static final Map<String, String> uniqueTypes = Collections.singletonMap("VspName", VENDOR_SOFTWARE_PRODUCT_NAME); - @Override - public Map<String, String> listUniqueTypes() { - return uniqueTypes; - } + @Override + public Map<String, String> listUniqueTypes() { + return uniqueTypes; + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentCreationDto.java index f633e2cbbb..3af2c9460a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentCreationDto.java @@ -1,24 +1,24 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class ComponentCreationDto { + private String vfcId; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyCreationDto.java index 50bd66f0a8..148549dda9 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyCreationDto.java @@ -1,24 +1,24 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class ComponentDependencyCreationDto { + private String id; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyModel.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyModel.java index b3a0620cc0..d05c4cde9c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyModel.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyModel.java @@ -1,19 +1,18 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyModelRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyModelRequestDto.java index 7a1d154bc1..66d641fb94 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyModelRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyModelRequestDto.java @@ -1,29 +1,25 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; - -import lombok.Data; - import java.util.List; +import lombok.Data; @Data public class ComponentDependencyModelRequestDto { private List<ComponentDependencyModel> componentDependencyModels; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyResponseDto.java index 4874efb287..e43e73899c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDependencyResponseDto.java @@ -1,25 +1,25 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class ComponentDependencyResponseDto { + private String sourceId; private String targetId; private String relationType; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDto.java index f9651e69e0..432c49cf31 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentDto.java @@ -1,24 +1,24 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class ComponentDto extends ComponentRequestDto implements CompositionDataEntityDto { + private String id; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRelationType.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRelationType.java index bf9e3f3b76..f6655aa071 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRelationType.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRelationType.java @@ -1,22 +1,18 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; -public enum ComponentRelationType { - dependsOn, - other -} +public enum ComponentRelationType {dependsOn, other} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRequestDto.java index a14e0825ca..b5fb60c6c3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentRequestDto.java @@ -1,25 +1,23 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; -import lombok.Data; - import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; +import lombok.Data; @Data public class ComponentRequestDto { @@ -29,5 +27,4 @@ public class ComponentRequestDto { @Size(min = 1, max = 30, message = "VFC displayName length should be between 1 and 30.") private String displayName; private String description; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentValidationResultDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentValidationResultDto.java index 1270212e4a..e02d64fb9a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentValidationResultDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComponentValidationResultDto.java @@ -1,28 +1,26 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; - -import lombok.Data; - import java.util.Set; +import lombok.Data; @Data public class ComponentValidationResultDto { + private boolean valid; private Set<CompositionEntityValidationDataDto> validationData; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionDataEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionDataEntityDto.java index 3e6607e0ea..1aa5d797c2 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionDataEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionDataEntityDto.java @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vendorsoftwareproducts.types; public interface CompositionDataEntityDto { + } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityResponseDto.java index 31bbfc2085..1c1f91e962 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityResponseDto.java @@ -1,25 +1,25 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class CompositionEntityResponseDto<T extends CompositionDataEntityDto> { + private String id; private String schema; private T data; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityValidationDataDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityValidationDataDto.java index 1848276706..5f2b85deb8 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityValidationDataDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/CompositionEntityValidationDataDto.java @@ -1,28 +1,27 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +import java.util.Collection; import lombok.Data; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType; -import java.util.Collection; - @Data public class CompositionEntityValidationDataDto { + private CompositionEntityType entityType; private String entityId; private String entityName; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeCreationDto.java index 3601d54a06..71358b8980 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeCreationDto.java @@ -1,24 +1,24 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class ComputeCreationDto { + private String id; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDescription.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDescription.java index 2bc27314fd..3320ab0dbb 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDescription.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDescription.java @@ -1,25 +1,25 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class ComputeDescription { + private String name; private String description; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDetailsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDetailsDto.java index 5e0de75a3a..843c5d5426 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDetailsDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDetailsDto.java @@ -1,32 +1,30 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +import javax.validation.constraints.Size; import lombok.Data; import org.hibernate.validator.constraints.NotBlank; -import javax.validation.constraints.Size; - @Data public class ComputeDetailsDto implements CompositionDataEntityDto { + @NotBlank(message = "is mandatory and should not be empty") @Size(min = 0, max = 30, message = "length should not exceed 30 characters.") private String name; @Size(min = 0, max = 300, message = "length should not exceed 300 characters.") private String description; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDto.java index 6f9aaa1571..e2c34dc23e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ComputeDto.java @@ -1,25 +1,25 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class ComputeDto { + private String name; private String id; private String description; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorCreationDto.java index 1fb65c4e09..e0e97db0f8 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorCreationDto.java @@ -1,24 +1,24 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class DeploymentFlavorCreationDto { + private String deploymentFlavorId; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorDto.java index e4eb4af3af..8a0d1059c6 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorDto.java @@ -1,24 +1,24 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class DeploymentFlavorDto extends DeploymentFlavorRequestDto implements CompositionDataEntityDto { + private String id; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorListResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorListResponseDto.java index db6850a6a9..b180ed5759 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorListResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorListResponseDto.java @@ -1,25 +1,25 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class DeploymentFlavorListResponseDto { + private String model; private String description; private String id; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorRequestDto.java index 2b34858ec1..3d29deb60b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorRequestDto.java @@ -1,31 +1,29 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; - +import java.util.List; +import javax.validation.constraints.Size; import lombok.Data; import org.hibernate.validator.constraints.NotBlank; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation; -import javax.validation.constraints.Size; -import java.util.List; - @Data public class DeploymentFlavorRequestDto { + @NotBlank(message = "is mandatory and should not be empty") @Size(min = 0, max = 30, message = "length should not exceed 30 characters.") private String model; @@ -33,5 +31,4 @@ public class DeploymentFlavorRequestDto { private String description; private String featureGroupId; private List<ComponentComputeAssociation> componentComputeAssociations; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorValidationResultDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorValidationResultDto.java index 7029bfcd4c..833636cccc 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorValidationResultDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/DeploymentFlavorValidationResultDto.java @@ -1,28 +1,26 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; - -import lombok.Data; - import java.util.Set; +import lombok.Data; @Data public class DeploymentFlavorValidationResultDto { + private boolean valid; private Set<CompositionEntityValidationDataDto> validationData; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/FileDataStructureDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/FileDataStructureDto.java index 166efec6fa..a98c515815 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/FileDataStructureDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/FileDataStructureDto.java @@ -1,33 +1,31 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +import java.util.List; import lombok.Data; import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.Module; -import java.util.List; - /** * @author Avrahamg * @since November 07, 2016 */ - @Data public class FileDataStructureDto { + private List<Module> modules; private List<String> unassigned; private List<String> artifacts; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageCreationDto.java index 96775a669b..b0af65c3d5 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageCreationDto.java @@ -1,24 +1,24 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class ImageCreationDto { + private String id; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageDto.java index 40105a6c47..0cfb9249ef 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageDto.java @@ -1,24 +1,24 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class ImageDto extends ImageRequestDto implements CompositionDataEntityDto { + private String id; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageRequestDto.java index 6081a32635..6a4f1a2702 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ImageRequestDto.java @@ -1,19 +1,18 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @@ -25,5 +24,4 @@ public class ImageRequestDto implements CompositionDataEntityDto { @NotBlank(message = "is mandatory and should not be empty") private String fileName; private String description; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/MonitoringUploadStatusDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/MonitoringUploadStatusDto.java index a8c1c58a71..b2512fa7b9 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/MonitoringUploadStatusDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/MonitoringUploadStatusDto.java @@ -1,27 +1,26 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class MonitoringUploadStatusDto { + private String snmpTrap; private String snmpPoll; private String vesEvent; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkDto.java index b944970d8b..4495d539d2 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkDto.java @@ -1,24 +1,24 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class NetworkDto extends NetworkRequestDto implements CompositionDataEntityDto { + private String id; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkRequestDto.java index 28cfbaa06d..f3e6d780dc 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NetworkRequestDto.java @@ -1,24 +1,22 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; -import lombok.Data; - import javax.validation.constraints.NotNull; +import lombok.Data; @Data public class NetworkRequestDto { @@ -27,5 +25,4 @@ public class NetworkRequestDto { private String name; @NotNull private boolean dhcp; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicCreationResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicCreationResponseDto.java index 47b57e8175..874e0dc054 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicCreationResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicCreationResponseDto.java @@ -1,24 +1,24 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class NicCreationResponseDto { + private String nicId; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicDto.java index 025e494ed0..578b2ec62a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicDto.java @@ -1,25 +1,25 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class NicDto extends NicRequestDto implements CompositionDataEntityDto { + private String id; private String networkName; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicRequestDto.java index 73246fd7ec..1bef41df40 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/NicRequestDto.java @@ -1,27 +1,25 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +import javax.validation.constraints.NotNull; import lombok.Data; import org.hibernate.validator.constraints.NotBlank; import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.ValidateString; -import javax.validation.constraints.NotNull; - @Data public class NicRequestDto { @@ -30,9 +28,7 @@ public class NicRequestDto { private String description; private String networkId; @NotNull - @ValidateString(acceptedValues = {"External", "Internal"}, message = "doesn't " - + "meet the expected attribute value.", isCaseSensitive = true) + @ValidateString(acceptedValues = {"External", "Internal"}, message = "doesn't " + "meet the expected attribute value.", isCaseSensitive = true) private String networkType; - private String networkDescription; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OrchestrationTemplateAction.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OrchestrationTemplateAction.java index e883913bb1..0478afecc0 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OrchestrationTemplateAction.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OrchestrationTemplateAction.java @@ -1,24 +1,21 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; /** * Created by Talio on 11/13/2016. */ -public enum OrchestrationTemplateAction { - Process -} +public enum OrchestrationTemplateAction {Process} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OrchestrationTemplateActionResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OrchestrationTemplateActionResponseDto.java index 36588e0f51..75683649e3 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OrchestrationTemplateActionResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/OrchestrationTemplateActionResponseDto.java @@ -1,33 +1,32 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +import java.util.List; +import java.util.Map; import lombok.Data; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileStatus; -import java.util.List; -import java.util.Map; - /** * Created by TALIO on 4/27/2016. */ @Data public class OrchestrationTemplateActionResponseDto { + private List<String> fileNames; private Map<String, List<ErrorMessage>> errors; private UploadFileStatus status; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/PackageInfoDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/PackageInfoDto.java index 12c29888ee..5650ac8670 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/PackageInfoDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/PackageInfoDto.java @@ -1,19 +1,18 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @@ -36,5 +35,4 @@ public class PackageInfoDto { private String packageChecksum; private String packageType; private String resourceType; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessEntityDto.java index fcea252fb9..642cbb6c46 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessEntityDto.java @@ -1,25 +1,25 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class ProcessEntityDto extends ProcessRequestDto { + private String id; private String artifactName; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessRequestDto.java index 3379dee8ca..d57a293ee4 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ProcessRequestDto.java @@ -1,26 +1,24 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +import javax.validation.constraints.NotNull; import lombok.Data; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType; -import javax.validation.constraints.NotNull; - @Data public class ProcessRequestDto { @@ -28,5 +26,4 @@ public class ProcessRequestDto { private String name; private String description; private ProcessType type; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireDto.java index 763ff71388..3fe9461bcc 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireDto.java @@ -1,24 +1,22 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; -import lombok.Data; - import java.util.HashMap; +import lombok.Data; /** * Created by ayalaben on 9/26/2017 @@ -32,6 +30,4 @@ public class QuestionnaireDto { public HashMap<String, String> getQuestionareData() { return questionareData; } - - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireResponseDto.java index 763737f36f..f40091ea12 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireResponseDto.java @@ -1,19 +1,18 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @@ -21,8 +20,8 @@ import org.openecomp.sdc.datatypes.error.ErrorMessage; @Data public class QuestionnaireResponseDto { + private String schema; private String data; private ErrorMessage errorMessage; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireValidationResultDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireValidationResultDto.java index f431d18a9f..4c98b6e7a8 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireValidationResultDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/QuestionnaireValidationResultDto.java @@ -1,28 +1,26 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; -import lombok.Data; - import java.util.Set; +import lombok.Data; @Data public class QuestionnaireValidationResultDto { + private boolean valid; private Set<CompositionEntityValidationDataDto> validationData; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/TranslatedFileDataDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/TranslatedFileDataDto.java index 23c4f75d74..ab9dae40f1 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/TranslatedFileDataDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/TranslatedFileDataDto.java @@ -1,19 +1,18 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @@ -32,5 +31,4 @@ public class TranslatedFileDataDto { private String vendorRelease; private String packageChecksum; private String packageType; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/UploadFileResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/UploadFileResponseDto.java index 7ff8af341d..f45884e21e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/UploadFileResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/UploadFileResponseDto.java @@ -1,36 +1,34 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +import java.util.List; +import java.util.Map; import lombok.Data; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileStatus; -import java.util.List; -import java.util.Map; - /** * Created by TALIO on 4/27/2016. */ @Data public class UploadFileResponseDto { + private Map<String, List<ErrorMessage>> errors; private UploadFileStatus status; private String onboardingOrigin; private String networkPackageName; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ValidationResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ValidationResponseDto.java index 6122e43ec2..4f548736df 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ValidationResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/ValidationResponseDto.java @@ -1,31 +1,30 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; -import lombok.Data; -import org.openecomp.sdcrests.common.types.ErrorCodeDto; -import org.openecomp.sdcrests.common.types.ErrorMessageDto; - import java.util.Collection; import java.util.List; import java.util.Map; +import lombok.Data; +import org.openecomp.sdcrests.common.types.ErrorCodeDto; +import org.openecomp.sdcrests.common.types.ErrorMessageDto; @Data public class ValidationResponseDto { + private boolean valid; private Collection<ErrorCodeDto> vspErrors; private Collection<ErrorCodeDto> licensingDataErrors; @@ -33,5 +32,4 @@ public class ValidationResponseDto { private QuestionnaireValidationResultDto questionnaireValidationResult; private ComponentValidationResultDto componentValidationResult; private DeploymentFlavorValidationResultDto deploymentFlavorValidationResult; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VendorSoftwareProductAction.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VendorSoftwareProductAction.java index eec79aab81..afe1d76309 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VendorSoftwareProductAction.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VendorSoftwareProductAction.java @@ -1,22 +1,18 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; -public enum VendorSoftwareProductAction { - Submit, - Create_Package -} +public enum VendorSoftwareProductAction {Submit, Create_Package} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VersionSoftwareProductActionRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VersionSoftwareProductActionRequestDto.java index 6c5b26ec5a..76f1f9313e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VersionSoftwareProductActionRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VersionSoftwareProductActionRequestDto.java @@ -1,19 +1,18 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @@ -24,7 +23,7 @@ import org.openecomp.sdcrests.item.types.SubmitRequestDto; */ @Data public class VersionSoftwareProductActionRequestDto { + private VendorSoftwareProductAction action; private SubmitRequestDto submitRequest; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VmSizing.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VmSizing.java index a4d923d369..5001828db8 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VmSizing.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VmSizing.java @@ -1,29 +1,28 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; -import lombok.Data; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.ValidateString; - import javax.validation.constraints.Max; import javax.validation.constraints.Min; +import lombok.Data; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.ValidateString; @Data public class VmSizing { + @Min(value = 1, message = "should be integer and > 0") @Max(value = 16, message = "should be integer and <= 16") private int numOfCPUs; @@ -33,11 +32,8 @@ public class VmSizing { private int persistentStorageVolumeSize; @Min(value = 1, message = "should be integer and > 0") private int ioOperationsPerSec; - @ValidateString(acceptedValues = {"1:1", "4:1", "16:1"}, message = "doesn't meet the expected " - + "attribute value.") + @ValidateString(acceptedValues = {"1:1", "4:1", "16:1"}, message = "doesn't meet the expected " + "attribute value.") private String cpuOverSubscriptionRatio; - @ValidateString(acceptedValues = {"1", "2", "4", "8"}, message = "doesn't meet the expected " - + "attribute value.") + @ValidateString(acceptedValues = {"1", "2", "4", "8"}, message = "doesn't meet the expected " + "attribute value.") private String memoryRAM; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspComputeDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspComputeDto.java index 467f5e9329..0c8fb1938a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspComputeDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspComputeDto.java @@ -1,25 +1,25 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; @Data public class VspComputeDto { + private String name; private String componentId; private String computeFlavorId; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java index 3cddb5d4e3..010e0d3818 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDescriptionDto.java @@ -1,29 +1,28 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +import javax.validation.constraints.NotNull; import lombok.Data; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.LicenseType; import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData; -import javax.validation.constraints.NotNull; - @Data public class VspDescriptionDto { + @NotNull private String name; @NotNull @@ -37,6 +36,7 @@ public class VspDescriptionDto { private String vendorName; @NotNull private String vendorId; // this will be populated with vlm id + private String licensingVersion; // this will be populated with vlm version private LicenseType licenseType; private LicensingData licensingData; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java index fbc51a414b..2acc27e95a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspDetailsDto.java @@ -1,19 +1,18 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import io.swagger.v3.oas.annotations.media.Schema; @@ -23,17 +22,16 @@ import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; /** * Created by TALIO on 4/25/2016. */ - @Data @Schema(description = "VspDetails") public class VspDetailsDto extends VspRequestDto { - private String id; - private String version; - private ValidationStructureList validationData; - private String candidateOnboardingOrigin; - private String onboardingOrigin; - private String networkPackageName; - private String owner; - private String status; + private String id; + private String version; + private ValidationStructureList validationData; + private String candidateOnboardingOrigin; + private String onboardingOrigin; + private String networkPackageName; + private String owner; + private String status; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspRequestDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspRequestDto.java index 59b565a669..13e21ba760 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspRequestDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/VspRequestDto.java @@ -1,28 +1,26 @@ /* -* Copyright © 2016-2018 European Support Limited -* -* 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. -*/ - + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ package org.openecomp.sdcrests.vendorsoftwareproducts.types; -import lombok.Data; - import javax.validation.constraints.NotNull; +import lombok.Data; @Data public class VspRequestDto extends VspDescriptionDto { + @NotNull private String onboardingMethod; - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/CustomJsonValidator.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/CustomJsonValidator.java index 9e0b08bd0d..aa17db257c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/CustomJsonValidator.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/CustomJsonValidator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,25 +17,20 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorsoftwareproducts.types.validation; -import org.openecomp.core.utilities.json.JsonUtil; - import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; - +import org.openecomp.core.utilities.json.JsonUtil; public class CustomJsonValidator implements ConstraintValidator<IsValidJson, String> { - @Override - public void initialize(IsValidJson stringEnumeration) { - } - - - @Override - public boolean isValid(String json, ConstraintValidatorContext context) { - return JsonUtil.isValidJson(json); - } + @Override + public void initialize(IsValidJson stringEnumeration) { + } + @Override + public boolean isValid(String json, ConstraintValidatorContext context) { + return JsonUtil.isValidJson(json); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/IsValidJson.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/IsValidJson.java index 27c6d65ba5..e775802b9d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/IsValidJson.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/IsValidJson.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,23 +17,24 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorsoftwareproducts.types.validation; - /** * @since July 13, 2016 */ -import org.openecomp.sdcrests.common.RestConstants; +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; -import javax.validation.Constraint; -import javax.validation.Payload; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.RUNTIME; +import javax.validation.Constraint; +import javax.validation.Payload; +import org.openecomp.sdcrests.common.RestConstants; /** * The interface Is valid json. @@ -43,31 +44,30 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; @Target({METHOD, FIELD, ANNOTATION_TYPE, PARAMETER, CONSTRUCTOR}) @Retention(RUNTIME) public @interface IsValidJson { - /** - * The constant message. - */ - String message = RestConstants.INVALID_JSON_ERROR_MESSAGE; - /** - * Message string. - * - * @return the string - */ - String message() default RestConstants.INVALID_JSON_ERROR_MESSAGE; + /** + * The constant message. + */ + String message = RestConstants.INVALID_JSON_ERROR_MESSAGE; - /** - * Groups class [ ]. - * - * @return the class [ ] - */ - Class<?>[] groups() default {}; - - /** - * Payload class [ ]. - * - * @return the class [ ] - */ - Class<? extends Payload>[] payload() default {}; -} + /** + * Message string. + * + * @return the string + */ + String message() default RestConstants.INVALID_JSON_ERROR_MESSAGE; + /** + * Groups class [ ]. + * + * @return the class [ ] + */ + Class<?>[] groups() default {}; + /** + * Payload class [ ]. + * + * @return the class [ ] + */ + Class<? extends Payload>[] payload() default {}; +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/StringValidator.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/StringValidator.java index c163fedec5..919f5df4c1 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/StringValidator.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/StringValidator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,40 +17,38 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.openecomp.sdcrests.vendorsoftwareproducts.types.validation; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; import java.util.ArrayList; import java.util.List; +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; public class StringValidator implements ConstraintValidator<ValidateString, String> { - private List<String> valueList; - boolean isCaseSensitive; + boolean isCaseSensitive; + private List<String> valueList; - @Override - public void initialize(ValidateString constraintAnnotation) { - valueList = new ArrayList<String>(); - isCaseSensitive = constraintAnnotation.isCaseSensitive(); - for (String val : constraintAnnotation.acceptedValues()) { - if (!isCaseSensitive) { - val = val.toUpperCase(); - } - valueList.add(val); + @Override + public void initialize(ValidateString constraintAnnotation) { + valueList = new ArrayList<String>(); + isCaseSensitive = constraintAnnotation.isCaseSensitive(); + for (String val : constraintAnnotation.acceptedValues()) { + if (!isCaseSensitive) { + val = val.toUpperCase(); + } + valueList.add(val); + } } - } - @Override - public boolean isValid(String value, ConstraintValidatorContext context) { - if (!isCaseSensitive) { - value = value.toUpperCase(); - } - if (value != null && !valueList.contains(value)) { - return false; + @Override + public boolean isValid(String value, ConstraintValidatorContext context) { + if (!isCaseSensitive) { + value = value.toUpperCase(); + } + if (value != null && !valueList.contains(value)) { + return false; + } + return true; } - return true; - } - } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/ValidateString.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/ValidateString.java index 4073463eaf..533fc6897a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/ValidateString.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/validation/ValidateString.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,18 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types.validation; -import javax.validation.Constraint; -import javax.validation.Payload; +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.CONSTRUCTOR; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.RUNTIME; +import javax.validation.Constraint; +import javax.validation.Payload; /** * The interface Validate string. @@ -37,24 +41,25 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; @Target({METHOD, FIELD, ANNOTATION_TYPE, PARAMETER, CONSTRUCTOR}) @Retention(RUNTIME) public @interface ValidateString { - /** - * The constant message. - */ - String message = ""; - /** - * Accepted values string [ ]. - * - * @return the string [ ] - */ - String[] acceptedValues(); + /** + * The constant message. + */ + String message = ""; + + /** + * Accepted values string [ ]. + * + * @return the string [ ] + */ + String[] acceptedValues(); - String message() default "{org.openecomp.sdcrests.vendorsoftwareproducts.types.validation" - + ".message}"; + String message() default "{org.openecomp.sdcrests.vendorsoftwareproducts.types.validation" + + ".message}"; - boolean isCaseSensitive() default false; + boolean isCaseSensitive() default false; - Class<?>[] groups() default {}; + Class<?>[] groups() default {}; - Class<? extends Payload>[] payload() default {}; + Class<? extends Payload>[] payload() default {}; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VnfPackageRepository.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VnfPackageRepository.java index 9617c61836..1412c332cb 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VnfPackageRepository.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VnfPackageRepository.java @@ -13,12 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest; import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.tags.Tags; import java.io.File; import javax.validation.constraints.NotNull; import javax.ws.rs.Consumes; @@ -30,15 +36,6 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.info.Info; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.tags.Tags; import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; import org.springframework.validation.annotation.Validated; @@ -52,31 +49,23 @@ public interface VnfPackageRepository extends VspEntities { @GET @Path("/vnfpackages") @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Operation(description = "Get VNF packages from VNF Repository", - summary = "Call VNF Repository to get VNF package details", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class)))) - Response getVnfPackages(@PathParam("vspId") String vspId, - @Parameter(description= "Version Id") @PathParam("versionId") String versionId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; + @Operation(description = "Get VNF packages from VNF Repository", summary = "Call VNF Repository to get VNF package details", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class)))) + Response getVnfPackages(@PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; @GET @Path("/vnfpackage/{csarId}/download") @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Operation(description = "Download VNF package from VNF Repository", - summary = "Download VNF package from VNF repository and send to client", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class)))) - Response downloadVnfPackage(@PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @PathParam("csarId") String csarId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; + @Operation(description = "Download VNF package from VNF Repository", summary = "Download VNF package from VNF repository and send to client", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = File.class)))) + Response downloadVnfPackage(@PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @PathParam("csarId") String csarId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; @POST @Path("/vnfpackage/{csarId}/import") @Produces(MediaType.APPLICATION_JSON) - @Operation(description = "Import VNF package from VNF Repository", - summary = "Call VNF Repository to download VNF package, validate it and send the response", - responses = @ApiResponse(content = @Content(schema = @Schema(implementation = UploadFileResponseDto.class)))) - Response importVnfPackage(@PathParam("vspId") String vspId, - @Parameter(description = "Version Id") @PathParam("versionId") String versionId, - @PathParam("csarId") String csarId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) throws Exception; - + @Operation(description = "Import VNF package from VNF Repository", summary = "Call VNF Repository to download VNF package, validate it and send the response", responses = @ApiResponse(content = @Content(schema = @Schema(implementation = UploadFileResponseDto.class)))) + Response importVnfPackage(@PathParam("vspId") String vspId, @Parameter(description = "Version Id") @PathParam("versionId") String versionId, + @PathParam("csarId") String csarId, + @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/vnf-repository-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VnfPackageRepositoryImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VnfPackageRepositoryImpl.java index 9ee86889f5..88ee6fa43d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VnfPackageRepositoryImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vnf-repository-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VnfPackageRepositoryImpl.java @@ -14,9 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.openecomp.sdcrests.vsp.rest.services; +import static javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION; +import static org.openecomp.core.utilities.file.FileUtils.getFileExtension; +import static org.openecomp.core.utilities.file.FileUtils.getNetworkPackageName; + import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.security.KeyManagementException; @@ -54,10 +57,6 @@ import org.openecomp.sdcrests.vsp.rest.mapping.MapUploadFileResponseToUploadFile import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import static javax.ws.rs.core.HttpHeaders.CONTENT_DISPOSITION; -import static org.openecomp.core.utilities.file.FileUtils.getFileExtension; -import static org.openecomp.core.utilities.file.FileUtils.getNetworkPackageName; - /** * Enables integration API interface with VNF Repository (VNFSDK). * <ol> @@ -80,20 +79,23 @@ public class VnfPackageRepositoryImpl implements VnfPackageRepository { try { SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(null, new TrustManager[]{new X509TrustManager() { - public void checkClientTrusted(X509Certificate[] c, String s) {} - public void checkServerTrusted(X509Certificate[] c, String s) {} - public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } - }}, new java.security.SecureRandom()); + public void checkClientTrusted(X509Certificate[] c, String s) { + } + + public void checkServerTrusted(X509Certificate[] c, String s) { + } - return ClientBuilder.newBuilder() - .sslContext(sslcontext) - .hostnameVerifier((a, b) -> true) - .build(); + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[0]; + } + }}, new java.security.SecureRandom()); + return ClientBuilder.newBuilder().sslContext(sslcontext).hostnameVerifier((a, b) -> true).build(); } catch (NoSuchAlgorithmException | KeyManagementException e) { LOGGER.error("Failed to initialize SSL unsecure context", e); } return ClientBuilder.newClient(); } + private final Configuration config; public VnfPackageRepositoryImpl(Configuration config) { @@ -120,35 +122,28 @@ public class VnfPackageRepositoryImpl implements VnfPackageRepository { public Response importVnfPackage(String vspId, String versionId, String csarId, String user) { LOGGER.debug("Import VNF Packages from Repository: {}", csarId); final String downloadPackageUri = String.format(config.getDownloadUri(), csarId); - Response remoteResponse = CLIENT.target(downloadPackageUri).request().get(); if (remoteResponse.getStatus() != Response.Status.OK.getStatusCode()) { return handleUnexpectedStatus("downloading VNF package", downloadPackageUri, remoteResponse); } - LOGGER.debug("Response from VNF Repository for download package is success. URI={}", downloadPackageUri); byte[] payload = remoteResponse.readEntity(String.class).getBytes(StandardCharsets.ISO_8859_1); return uploadVnfPackage(vspId, versionId, csarId, payload); } - private Response uploadVnfPackage(final String vspId, final String versionId, - final String csarId, final byte[] payload) { + private Response uploadVnfPackage(final String vspId, final String versionId, final String csarId, final byte[] payload) { try { - final OrchestrationTemplateCandidateManager candidateManager = - OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface(); + final OrchestrationTemplateCandidateManager candidateManager = OrchestrationTemplateCandidateManagerFactory.getInstance() + .createInterface(); final String filename = formatFilename(csarId); final String fileExtension = getFileExtension(filename); - final OnboardPackageInfo onboardPackageInfo = - new OnboardPackageInfo(getNetworkPackageName(filename), fileExtension, ByteBuffer.wrap(payload), - OnboardingTypesEnum.getOnboardingTypesEnum(fileExtension)); + final OnboardPackageInfo onboardPackageInfo = new OnboardPackageInfo(getNetworkPackageName(filename), fileExtension, + ByteBuffer.wrap(payload), OnboardingTypesEnum.getOnboardingTypesEnum(fileExtension)); final VspDetails vspDetails = new VspDetails(vspId, getVersion(vspId, versionId)); final UploadFileResponse response = candidateManager.upload(vspDetails, onboardPackageInfo); - final UploadFileResponseDto uploadFileResponse = - new MapUploadFileResponseToUploadFileResponseDto() - .applyMapping(response, UploadFileResponseDto.class); - + final UploadFileResponseDto uploadFileResponse = new MapUploadFileResponseToUploadFileResponseDto() + .applyMapping(response, UploadFileResponseDto.class); return Response.ok(uploadFileResponse).build(); - } catch (final Exception e) { ErrorCode error = new GeneralErrorBuilder().build(); LOGGER.error("Exception while uploading package received from VNF Repository", new CoreException(error, e)); @@ -160,16 +155,13 @@ public class VnfPackageRepositoryImpl implements VnfPackageRepository { public Response downloadVnfPackage(String vspId, String versionId, String csarId, String user) { LOGGER.debug("Download VNF package from repository: csarId={}", csarId); final String downloadPackageUri = String.format(config.getDownloadUri(), csarId); - Response remoteResponse = CLIENT.target(downloadPackageUri).request().get(); if (remoteResponse.getStatus() != Response.Status.OK.getStatusCode()) { return handleUnexpectedStatus("downloading VNF package", downloadPackageUri, remoteResponse); } - byte[] payload = remoteResponse.readEntity(String.class).getBytes(StandardCharsets.ISO_8859_1); Response.ResponseBuilder response = Response.ok(payload); response.header(CONTENT_DISPOSITION, "attachment; filename=" + formatFilename(csarId)); - LOGGER.debug("Response from VNF Repository for download package is success. URI={}", downloadPackageUri); return response.build(); } @@ -184,15 +176,12 @@ public class VnfPackageRepositoryImpl implements VnfPackageRepository { } private static Response handleUnexpectedStatus(String action, String uri, Response response) { - ErrorCode error = new GeneralErrorBuilder().build(); - if (LOGGER.isErrorEnabled()) { String body = response.hasEntity() ? response.readEntity(String.class) : ""; - LOGGER.error("Unexpected response status while {}: URI={}, status={}, body={}", action, uri, - response.getStatus(), body, new CoreException(error)); + LOGGER.error("Unexpected response status while {}: URI={}, status={}, body={}", action, uri, response.getStatus(), body, + new CoreException(error)); } - return generateInternalServerError(error); } @@ -206,7 +195,9 @@ public class VnfPackageRepositoryImpl implements VnfPackageRepository { } interface Configuration { + String getGetUri(); + String getDownloadUri(); } @@ -225,16 +216,12 @@ public class VnfPackageRepositoryImpl implements VnfPackageRepository { private static class LazyFileConfiguration implements Configuration { private static final String CONFIG_NAMESPACE = "vnfrepo"; - private static final String DEFAULT_HOST = "localhost"; private static final String DEFAULT_PORT = "8702"; - private static final String DEFAULT_URI_PREFIX = "/onapapi/vnfsdk-marketplace/v1/PackageResource/csars"; private static final String DEFAULT_LIST_URI = DEFAULT_URI_PREFIX + "/"; private static final String DEFAULT_DOWNLOAD_URI = DEFAULT_URI_PREFIX + "/%s/files"; - private static final LazyFileConfiguration INSTANCE = new LazyFileConfiguration(); - private final String getUri; private final String downloadUri; @@ -253,8 +240,7 @@ public class VnfPackageRepositoryImpl implements VnfPackageRepository { String value = config.getAsString(CONFIG_NAMESPACE, key); return (value == null) ? defaultValue : value; } catch (Exception e) { - LOGGER.error("Failed to read VNF repository configuration key '{}', default value '{}' will be used", - key, defaultValue, e); + LOGGER.error("Failed to read VNF repository configuration key '{}', default value '{}' will be used", key, defaultValue, e); return defaultValue; } } |