diff options
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp')
150 files changed, 5003 insertions, 1693 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml index 8ee3283769..8b473a4b7c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml @@ -4,15 +4,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <artifactId>action-library-rest-services</artifactId> <parent> <groupId>org.openecomp.sdc.onboarding</groupId> <artifactId>action-library-rest</artifactId> <version>1.1.0-SNAPSHOT</version> </parent> - <artifactId>action-library-rest-services</artifactId> - - <properties> <errorcode.dir>${project.build.directory}/generated-sources/error-codes</errorcode.dir> @@ -58,7 +56,6 @@ <artifactId>cxf-rt-frontend-jaxrs</artifactId> <version>${cxf.version}</version> </dependency> - <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> @@ -77,12 +74,12 @@ </dependency> <!-- Other Stuff--> - <dependency> + <!--dependency> <groupId>cglib</groupId> <artifactId>cglib-nodep</artifactId> <version>${cglib.nodep.version}</version> <scope>runtime</scope> - </dependency> + </dependency--> <!-- Java Stuff --> <dependency> @@ -102,13 +99,23 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.sdc.sdc_common</groupId> - <artifactId>openecomp-logging-api</artifactId> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-logging-api</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>${slf4j.version}</version> + </dependency> + <dependency> + <groupId>com.sun.jersey.contribs</groupId> + <artifactId>jersey-multipart</artifactId> + <version>${jersey.multipart.version}</version> + <scope>provided</scope> + </dependency> </dependencies> - <build> <plugins> <plugin> @@ -121,10 +128,15 @@ <skipTests>true</skipTests> </configuration> </plugin> + <!-- Error codes generator plugin --> + <!--plugin> + <groupId>org.openecomp.nfv.tools</groupId> + <artifactId>error-codes-maven-plugin</artifactId> + </plugin--> </plugins> </build> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml.versionsBackup new file mode 100644 index 0000000000..47b9bdde7b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml.versionsBackup @@ -0,0 +1,143 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>action-library-rest-services</artifactId> + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>action-library-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + + <properties> + <errorcode.dir>${project.build.directory}/generated-sources/error-codes</errorcode.dir> + </properties> + + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>action-library-rest-types</artifactId> + <version>${project.version}</version> + </dependency> + + <!-- Spring --> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context-support</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>${spring.framework.version}</version> + </dependency> + + <!-- CXF --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>${http.client.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore</artifactId> + <version>${http.client.version}</version> + </dependency> + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + + <!-- Other Stuff--> + <!--dependency> + <groupId>cglib</groupId> + <artifactId>cglib-nodep</artifactId> + <version>${cglib.nodep.version}</version> + <scope>runtime</scope> + </dependency--> + + <!-- Java Stuff --> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>${javax.inject.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-action-manager</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-action-api</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-logging-api</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.21</version> + </dependency> + <dependency> + <groupId>com.sun.jersey.contribs</groupId> + <artifactId>jersey-multipart</artifactId> + <version>1.18.1</version> + <scope>provided</scope> + </dependency> + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>test/core/unittest/offline/**</include> + </includes> + <skipTests>true</skipTests> + </configuration> + </plugin> + <!-- Error codes generator plugin --> + <!--plugin> + <groupId>org.openecomp.nfv.tools</groupId> + <artifactId>error-codes-maven-plugin</artifactId> + </plugin--> + </plugins> + </build> + + + + +</project>
\ No newline at end of file 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 c7e3bbddec..7e96793a43 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 @@ -53,22 +53,22 @@ import javax.ws.rs.core.Response; public interface Actions { /** - * List All Major, Last Minor and Candidate version if any for Given Action Invariant UUID + * 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 + actionInvariantUuId. If actionUuId is provided then only action with given actionInvariantUuId + and actionUuId */ @GET - @Path("/{actionInvariantUUID}") - @ApiOperation(value = "List Actions For Given Action Invariant UUID", responseContainer = "List") + @Path("/{actionInvariantUuId}") + @ApiOperation(value = "List Actions For Given Action Invariant UuId", responseContainer = "List") Response getActionsByActionInvariantUuId( - @PathParam("actionInvariantUUID") String actionInvariantUuId, + @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 + * 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 */ @@ -85,20 +85,20 @@ public interface Actions { @Context HttpServletRequest servletRequest); /** - * List ECOMP Components supported by Action Library. + * List OPENECOMP Components supported by Action Library. * - * @return List of ECOMP Components supported by Action Library. + * @return List of OPENECOMP Components supported by Action Library */ @GET @Path("/components") - @ApiOperation(value = "List ECOMP Components supported by Action Library", + @ApiOperation(value = "List OPENECOMP Components supported by Action Library", responseContainer = "List") - Response getEcompComponents(@Context HttpServletRequest servletRequest); + Response getOpenEcompComponents(@Context HttpServletRequest servletRequest); /** * Create a new Action based on request JSON. * - * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action. + * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action */ @POST @ApiOperation(value = "Create a new Action") @@ -107,34 +107,34 @@ public interface Actions { /** * Update an existing action with parameters provided in requestJson. * - * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action. + * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action */ @PUT - @Path("/{actionInvariantUUID}") + @Path("/{actionInvariantUuId}") @ApiOperation(value = "Update an existing action") - Response updateAction(@PathParam("actionInvariantUUID") String actionInvariantUuId, + 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. + * @param actionInvariantUuId Invariant UuId of the action to be deleted + * @param servletRequest Servlet request object + * @return Empty response object */ @DELETE - @Path("/{actionInvariantUUID}") + @Path("/{actionInvariantUuId}") @ApiOperation(value = "Delete Action") - Response deleteAction(@PathParam("actionInvariantUUID") String actionInvariantUuId, + 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. + * @return Metadata object {@link ActionResponseDto ActionResponseDto} object for created Action */ @POST - @Path("/{actionInvariantUUID}") + @Path("/{actionInvariantUuId}") @ApiOperation(value = "Actions on a action", notes = "Performs one of the following actions on a action: |" + "Checkout: Locks it for edits by other users. Only the locking user sees the edited " @@ -142,65 +142,63 @@ public interface Actions { + "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, + 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. + * @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") - @ApiOperation(value = "Upload new Artifact") + @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); + 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); @GET - @Path("/{actionUUID}/artifacts/{artifactUUID}") + @Path("/{actionUuId}/artifacts/{artifactUuId}") @Produces(MediaType.APPLICATION_OCTET_STREAM) @ApiOperation(value = "Downloads artifact for action") - Response downloadArtifact(@PathParam("actionUUID") String actionUuId, - @PathParam("artifactUUID") String artifactUuId, + Response downloadArtifact(@PathParam("actionUuId") String actionUuId, + @PathParam("artifactUuId") String artifactUuId, @Context HttpServletRequest servletRequest); @DELETE - @Path("/{actionInvariantUUID}/artifacts/{artifactUUID}") + @Path("/{actionInvariantUuId}/artifacts/{artifactUuId}") @ApiOperation(value = "Delete Artifact") - Response deleteArtifact(@PathParam("actionInvariantUUID") String actionInvariantUuId, - @PathParam("artifactUUID") String artifactUuId, + Response deleteArtifact(@PathParam("actionInvariantUuId") String actionInvariantUuId, + @PathParam("artifactUuId") String artifactUuId, @Context HttpServletRequest servletRequest); @PUT - @Path("/{actionInvariantUUID}/artifacts/{artifactUUID}") - @ApiOperation(value = "Update an existing artifact") + @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); + 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 new file mode 100644 index 0000000000..369e90c928 --- /dev/null +++ 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 @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.action.rest; + +import com.sun.jersey.multipart.FormDataParam; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.springframework.validation.annotation.Validated; + +import javax.servlet.http.HttpServletRequest; +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; + + +@Path("/workflow/v1.0/actions") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Actions") +@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") + @ApiOperation(value = "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}") + @ApiOperation(value = "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 27d3f482c7..9ef1f119f0 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 @@ -24,7 +24,6 @@ import org.openecomp.sdc.action.types.Action; import org.openecomp.sdcrests.action.types.ActionResponseDto; import org.openecomp.sdcrests.mapping.MappingBase; - /** * Maps Source Action Object To Action Response DTO. */ 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 7e9cca0e0b..2ed5235867 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 @@ -20,7 +20,6 @@ package org.openecomp.sdcrests.action.rest.services; -import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_END_POINT_URI; import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_NAME; import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_SUPPORTED_COMPONENTS; import static org.openecomp.sdc.action.ActionConstants.ACTION_REQUEST_PARAM_SUPPORTED_MODELS; @@ -31,7 +30,7 @@ import static org.openecomp.sdc.action.ActionConstants.CATEGORY_LOG_LEVEL; import static org.openecomp.sdc.action.ActionConstants.CLIENT_IP; import static org.openecomp.sdc.action.ActionConstants.ERROR_DESCRIPTION; import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_CATEGORY; -import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_ECOMP_COMPONENT; +import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_OPEN_ECOMP_COMPONENT; import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_MODEL; import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NAME; import static org.openecomp.sdc.action.ActionConstants.FILTER_TYPE_NONE; @@ -59,8 +58,8 @@ import static org.openecomp.sdc.action.ActionConstants.TARGET_ENTITY_API; import static org.openecomp.sdc.action.ActionConstants.TARGET_SERVICE_NAME; import static org.openecomp.sdc.action.ActionConstants.TIMESTAMP; import static org.openecomp.sdc.action.ActionConstants.UPDATED_BY; -import static org.openecomp.sdc.action.ActionConstants.X_ECOMP_INSTANCE_ID_HEADER_PARAM; -import static org.openecomp.sdc.action.ActionConstants.X_ECOMP_REQUEST_ID_HEADER_PARAM; +import static org.openecomp.sdc.action.ActionConstants.X_OPEN_ECOMP_INSTANCE_ID_HEADER_PARAM; +import static org.openecomp.sdc.action.ActionConstants.X_OPEN_ECOMP_REQUEST_ID_HEADER_PARAM; import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_CHECKSUM_ERROR_CODE; import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_NAME; import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_ARTIFACT_INVALID_NAME_CODE; @@ -84,8 +83,8 @@ import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUES import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ARTIFACT_OPERATION_ALLOWED; import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_BODY_EMPTY; import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_CONTENT_TYPE_INVALID; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ECOMP_INSTANCE_ID_INVALID; -import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_ECOMP_REQUEST_ID_INVALID; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_OPEN_ECOMP_INSTANCE_ID_INVALID; +import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_OPEN_ECOMP_REQUEST_ID_INVALID; import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_FILTER_PARAM_INVALID; import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_INVALID_GENERIC_CODE; import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_REQUEST_INVALID_NAME; @@ -94,12 +93,13 @@ import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UNSUPP import static org.openecomp.sdc.action.errors.ActionErrorConstants.ACTION_UPDATE_NOT_ALLOWED_CODE; import static org.openecomp.sdc.action.util.ActionUtil.actionErrorLogProcessor; import static org.openecomp.sdc.action.util.ActionUtil.actionLogPostProcessor; +import static org.openecomp.sdc.action.util.ActionUtil.getUtcDateStringFromTimestamp; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang3.StringUtils; import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.openecomp.core.logging.api.Logger; -import org.openecomp.core.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.sdc.action.ActionConstants; @@ -112,7 +112,7 @@ import org.openecomp.sdc.action.types.Action; import org.openecomp.sdc.action.types.ActionArtifact; import org.openecomp.sdc.action.types.ActionArtifactProtection; import org.openecomp.sdc.action.types.ActionRequest; -import org.openecomp.sdc.action.types.EcompComponent; +import org.openecomp.sdc.action.types.OpenEcompComponent; import org.openecomp.sdcrests.action.rest.Actions; import org.openecomp.sdcrests.action.rest.mapping.MapActionToActionResponseDto; import org.openecomp.sdcrests.action.types.ActionResponseDto; @@ -129,23 +129,17 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.text.DateFormat; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.TimeZone; 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. + * Implements various CRUD API that can be performed on Action */ @SuppressWarnings("ALL") @Named @@ -154,10 +148,9 @@ import javax.ws.rs.core.Response; @Validated public class ActionsImpl implements Actions { + private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName()); @Autowired private ActionManager actionManager; - private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName()); - private String whitespaceCharacters = "\\s" /* dummy empty string for homogeneity */ + "\\u0009" // CHARACTER TABULATION + "\\u000A" // LINE FEED (LF) @@ -191,10 +184,10 @@ public class ActionsImpl implements Actions { private String invalidFilenameRegex = ".*[" + whitespaceCharacters + invalidFilenameChars + "].*"; /** - * Calculate the checksum for a given input. + * 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. + * @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; @@ -204,168 +197,128 @@ public class ActionsImpl implements Actions { return checksum; } - /** - * Convert timestamp to UTC format date string. - * - * @param timeStamp UTC timestamp to be converted to the UTC Date format. - * @return UTC formatted Date string from timestamp. - */ - public static String getUTCDateStringFromTimestamp(Date timeStamp) { - DateFormat df = new SimpleDateFormat("dd MMM yyyy kk:mm:ss z"); - df.setTimeZone(TimeZone.getTimeZone("GMT")); - return df.format(timeStamp); - } - /** - * 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_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, StatusCode.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(log.isDebugEnabled()) - MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.DEBUG.name()); - else if(log.isInfoEnabled()) - MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.INFO.name()); - else if(log.isWarnEnabled()) - MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.WARN.name()); - else if(log.isErrorEnabled()) - MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.ERROR.name()); - } - @Override - public Response getActionsByActionInvariantUuId(String invariantId, String actionUuId, + public Response getActionsByActionInvariantUuId(String invariantID, String actionUUID, HttpServletRequest servletRequest) { ListResponseWrapper responseList = new ListResponseWrapper(); - try{ - log.debug(" entering getActionsByActionInvariantUUID "); - initializeRequestMDC(servletRequest, invariantId, ActionRequest.GET_ACTIONS_INVARIANT_ID); - MDC.put(SERVICE_INSTANCE_ID, invariantId); + try { + log.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); + if (StringUtils.isEmpty(servletRequest.getQueryString())) { + responseList = getActionsByInvId(servletRequest, invariantID); + } else { + Response response = getActionByUUID(servletRequest, invariantID, actionUUID); actionLogPostProcessor(StatusCode.COMPLETE, true); return response; } - } catch (ActionException e){ - actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + } catch (ActionException exception) { + actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); log.error(""); - throw e; - } catch (Exception e){ + throw exception; + } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, + ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); log.error(""); - throw e; + throw exception; } finally { finalAuditMetricsLogProcessor(ActionRequest.GET_ACTIONS_INVARIANT_ID.name()); } - log.debug(" exit getActionsByActionInvariantUUID " ); + log.debug(" exit getActionsByActionInvariantUuId "); actionLogPostProcessor(StatusCode.COMPLETE, true); return Response.ok(responseList).build(); } - private ListResponseWrapper getActionsByInvId(HttpServletRequest servletRequest, String invariantId){ - log.debug(" entering getActionsByInvId with invariantId= " + invariantId ); + private ListResponseWrapper getActionsByInvId(HttpServletRequest servletRequest, + String invariantID) { + log.debug(" entering getActionsByInvId with invariantID= " + invariantID); ListResponseWrapper responseList = new ListResponseWrapper(); - if(StringUtils.isEmpty(servletRequest.getQueryString())){ + if (StringUtils.isEmpty(servletRequest.getQueryString())) { Map<String, String> errorMap = validateRequestHeaders(servletRequest); - Map<String, String> queryParamErrors = validateQueryParam(invariantId); + Map<String, String> queryParamErrors = validateQueryParam(invariantID); errorMap.putAll(queryParamErrors); - if(errorMap.isEmpty()) { - List<Action> actions = actionManager.getActionsByActionInvariantUuId(invariantId); + if (errorMap.isEmpty()) { + List<Action> actions = actionManager.getActionsByActionInvariantUuId(invariantID); List<ActionResponseDto> versionList = new ArrayList<ActionResponseDto>(); for (Action action : actions) { ActionResponseDto responseDTO = createResponseDTO(action); versionList.add(responseDTO); } - responseList .setVersions(versionList); + responseList.setVersions(versionList); responseList.setActionList(null); - } else{ + } else { checkAndThrowError(errorMap); } } - log.debug(" exit getActionsByInvId with invariantId= " + invariantId ); + log.debug(" exit getActionsByInvId with invariantID= " + invariantID); return responseList; } - private Response getActionByUUID(HttpServletRequest servletRequest, String invariantID, String actionUUID) throws ActionException{ + private Response getActionByUUID(HttpServletRequest servletRequest, String invariantID, + String actionUUID) throws ActionException { int noOfFilterParams = 0; Response response = null; - log.debug(" entering getActionByUUID with invariantID= " + invariantID + " and actionUUID= " + actionUUID); - if(!StringUtils.isEmpty(actionUUID)) { - noOfFilterParams ++; - response = getActionsByUniqueID(actionUUID, servletRequest, invariantID); + log.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); } - if(noOfFilterParams == 0) - throw new ActionException(ACTION_INVALID_SEARCH_CRITERIA, ACTION_REQUEST_FILTER_PARAM_INVALID); - log.debug(" exit getActionByUUID with invariantID= " + invariantID + " and actionUUID= " + actionUUID); + log.debug(" exit getActionByUUID with invariantID= " + invariantID + " and actionUUID= " + + actionUUID); return response; } - private void finalAuditMetricsLogProcessor(String targetServiceName) { - MDC.put(TARGET_SERVICE_NAME, targetServiceName); - MDC.put(TARGET_ENTITY, TARGET_ENTITY_API); - log.metrics(""); - log.audit(""); - } - @Override - public Response getEcompComponents(HttpServletRequest servletRequest) { + public Response getOpenEcompComponents(HttpServletRequest servletRequest) { try { - log.debug(" entering getECOMPComponents "); - initializeRequestMDC(servletRequest, "", ActionRequest.GET_ECOMP_COMPONENTS); + log.debug(" entering getOpenEcompComponents "); + 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<EcompComponent> ecompComponents = actionManager.getEcompComponents(); + List<OpenEcompComponent> openEcompComponents = actionManager.getOpenEcompComponents(); response.setActionList(null); - response.setComponentList(ecompComponents); - log.debug(" exit getECOMPComponents "); + response.setComponentList(openEcompComponents); + log.debug(" exit getOpenEcompComponents "); actionLogPostProcessor(StatusCode.COMPLETE, true); return Response.ok(response).build(); - }catch (ActionException e){ - actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + } catch (ActionException exception) { + actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); log.error(""); - throw e; - } - catch (Exception e){ + throw exception; + } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, + ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); log.error(""); - throw e; - } - finally { - finalAuditMetricsLogProcessor(ActionRequest.GET_ECOMP_COMPONENTS.name()); + throw exception; + } finally { + finalAuditMetricsLogProcessor(ActionRequest.GET_OPEN_ECOMP_COMPONENTS.name()); } } @Override - public Response getFilteredActions(String vendor, String category, String name, String modelId, - String componentId, HttpServletRequest servletRequest) { + public Response getFilteredActions(String vendor, String category, String name, String modelID, + String componentID, HttpServletRequest servletRequest) { try { log.debug(" entering getFilteredActions "); - int noOfFilterParams = 0; Response response = null; initializeRequestMDC(servletRequest, "", ActionRequest.GET_FILTERED_ACTIONS); + int noOfFilterParams = 0; if (!StringUtils.isEmpty(vendor)) { noOfFilterParams++; } @@ -375,10 +328,10 @@ public class ActionsImpl implements Actions { if (!StringUtils.isEmpty(name)) { noOfFilterParams++; } - if (!StringUtils.isEmpty(modelId)) { + if (!StringUtils.isEmpty(modelID)) { noOfFilterParams++; } - if (!StringUtils.isEmpty(componentId)) { + if (!StringUtils.isEmpty(componentID)) { noOfFilterParams++; } if (StringUtils.isEmpty(servletRequest.getQueryString())) { @@ -389,11 +342,11 @@ public class ActionsImpl implements Actions { } if (noOfFilterParams > 1) { throw new ActionException(ACTION_MULT_SEARCH_CRITERIA, - ACTION_FILTER_MULTIPLE_QUERY_PARAM_NOT_SUPPORTED); + ACTION_FILTER_MULTIPLE_QUERY_PARAM_NOT_SUPPORTED); } if (noOfFilterParams == 0) { throw new ActionException(ACTION_INVALID_SEARCH_CRITERIA, - ACTION_REQUEST_FILTER_PARAM_INVALID); + ACTION_REQUEST_FILTER_PARAM_INVALID); } ListResponseWrapper responseList = null; if (!StringUtils.isEmpty(vendor)) { @@ -402,154 +355,157 @@ public class ActionsImpl implements Actions { 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 = getActionsByECOMPComponent(componentId, 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); } + log.debug(" exit getFilteredActions "); actionLogPostProcessor(StatusCode.COMPLETE, true); return response; - } - catch (ActionException e){ - actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + } catch (ActionException exception) { + actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); log.error(""); - throw e; - } - catch (Exception e){ + throw exception; + } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, + ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); log.error(""); - throw e; - } - finally { + throw exception; + } finally { finalAuditMetricsLogProcessor(ActionRequest.GET_FILTERED_ACTIONS.name()); } } @Override - public Response createAction(String requestJson, HttpServletRequest servletRequest) { + public Response createAction(String requestJSON, HttpServletRequest servletRequest) { try { initializeRequestMDC(servletRequest, null, ActionRequest.CREATE_ACTION); log.debug(" entering API createAction "); Map<String, String> errorMap = validateRequestHeaders(servletRequest); Map<String, String> requestBodyErrors = - validateRequestBody(REQUEST_TYPE_CREATE_ACTION, requestJson); + validateRequestBody(REQUEST_TYPE_CREATE_ACTION, requestJSON); errorMap.putAll(requestBodyErrors); - ActionResponseDto actionResponseDto = new ActionResponseDto(); + ActionResponseDto actionResponseDTO = new ActionResponseDto(); if (errorMap.isEmpty()) { String user = servletRequest.getRemoteUser(); - Action action = JsonUtil.json2Object(requestJson, Action.class); - action.setData(requestJson); + 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); + new MapActionToActionResponseDto().doMapping(responseAction, actionResponseDTO); } else { checkAndThrowError(errorMap); } actionLogPostProcessor(StatusCode.COMPLETE, true); log.debug(" exit API createAction with ActionInvariantUUID= " + MDC.get(SERVICE_INSTANCE_ID)); - return Response.ok(actionResponseDto).build(); - }catch (ActionException e){ - actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + return Response.ok(actionResponseDTO).build(); + } catch (ActionException exception) { + actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); log.error(""); - throw e; - }catch (Exception e){ + throw exception; + } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(e.getMessage()); - throw e; - }finally { + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, + ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(exception.getMessage()); + throw exception; + } finally { finalAuditMetricsLogProcessor(ActionRequest.CREATE_ACTION.name()); } } @Override - public Response updateAction(String actionInvariantUuId, String requestJson, + public Response updateAction(String invariantUUID, String requestJSON, HttpServletRequest servletRequest) { + ActionResponseDto actionResponseDTO = null; try { - initializeRequestMDC(servletRequest, actionInvariantUuId, ActionRequest.UPDATE_ACTION); - log.debug(" entering API updateAction "); + initializeRequestMDC(servletRequest, invariantUUID, ActionRequest.UPDATE_ACTION); Map<String, String> errorMap = validateRequestHeaders(servletRequest); Map<String, String> requestBodyErrors = - validateRequestBody(REQUEST_TYPE_UPDATE_ACTION, requestJson); + validateRequestBody(REQUEST_TYPE_UPDATE_ACTION, requestJSON); errorMap.putAll(requestBodyErrors); - ActionResponseDto actionResponseDto = new ActionResponseDto(); + actionResponseDTO = new ActionResponseDto(); if (errorMap.isEmpty()) { String user = servletRequest.getRemoteUser(); - Action action = JsonUtil.json2Object(requestJson, Action.class); - action.setActionInvariantUuId(actionInvariantUuId); - action.setData(requestJson); + Action action = JsonUtil.json2Object(requestJSON, Action.class); + action.setActionInvariantUuId(invariantUUID); + action.setData(requestJSON); Action updatedAction = actionManager.updateAction(action, user); - new MapActionToActionResponseDto().doMapping(updatedAction, actionResponseDto); + new MapActionToActionResponseDto().doMapping(updatedAction, actionResponseDTO); } else { checkAndThrowError(errorMap); } actionLogPostProcessor(StatusCode.COMPLETE, true); - log.debug(" exit API updateAction "); - return Response.ok(actionResponseDto).build(); - }catch (ActionException e){ - actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + } catch (ActionException exception) { + actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); log.error(""); - throw e; - }catch (Exception e){ + throw exception; + } catch (Exception exception) { actionLogPostProcessor(StatusCode.ERROR, true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(e.getMessage()); - throw e; - }finally { + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, + ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(exception.getMessage()); + throw exception; + } finally { finalAuditMetricsLogProcessor(ActionRequest.UPDATE_ACTION.name()); } + + return Response.ok(actionResponseDTO).build(); } @Override - public Response deleteAction(String actionInvariantUuId, HttpServletRequest servletRequest) { + public Response deleteAction(String actionInvariantUUID, HttpServletRequest servletRequest) { try { - log.debug(" entering API deleteAction "); - initializeRequestMDC(servletRequest, actionInvariantUuId, ActionRequest.DELETE_ACTION); + initializeRequestMDC(servletRequest, actionInvariantUUID, ActionRequest.DELETE_ACTION); Map<String, String> errorMap = validateRequestHeaders(servletRequest); if (errorMap.isEmpty()) { String user = servletRequest.getRemoteUser(); - actionManager.deleteAction(actionInvariantUuId, user); + actionManager.deleteAction(actionInvariantUUID, user); } else { checkAndThrowError(errorMap); } + actionLogPostProcessor(StatusCode.COMPLETE, true); - log.debug(" exit API deleteAction "); return Response.ok(new ActionResponseDto()).build(); - }catch (ActionException e){ - actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + } catch (ActionException exception) { + actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); log.error(MDC.get(ERROR_DESCRIPTION)); - throw e; - }catch (Exception e){ - actionLogPostProcessor(StatusCode.ERROR,true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(e.getMessage()); - throw e; - }finally { + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(StatusCode.ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, + ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(exception.getMessage()); + throw exception; + } finally { finalAuditMetricsLogProcessor(ActionRequest.DELETE_ACTION.name()); } } @Override - public Response actOnAction(String actionInvariantUuId, String requestJson, + public Response actOnAction(String invariantUUID, String requestJSON, HttpServletRequest servletRequest) { Response response = null; try { - initializeRequestMDC(servletRequest,actionInvariantUuId,ActionRequest.ACTION_VERSIONING); - log.debug("entering actOnAction with invariantUUID= "+ actionInvariantUuId + " and requestJSON= "+ requestJson ); + initializeRequestMDC(servletRequest, invariantUUID, ActionRequest.ACTION_VERSIONING); + log.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); + validateRequestBody(REQUEST_TYPE_VERSION_ACTION, requestJSON); errorMap.putAll(requestBodyErrors); - ActionVersionDto versionDTO = JsonUtil.json2Object(requestJson, ActionVersionDto.class); + + ActionVersionDto versionDTO = JsonUtil.json2Object(requestJSON, ActionVersionDto.class); checkAndThrowError(errorMap); String status = versionDTO.getStatus(); @@ -557,51 +513,53 @@ public class ActionsImpl implements Actions { String user = servletRequest.getRemoteUser(); switch (status) { case "Checkout": - action = actionManager.checkout(actionInvariantUuId, user); + action = actionManager.checkout(invariantUUID, user); break; case "Undo_Checkout": - actionManager.undoCheckout(actionInvariantUuId, user); + actionManager.undoCheckout(invariantUUID, user); StringWrapperResponse responseText = new StringWrapperResponse(); responseText.setValue(ActionConstants.UNDO_CHECKOUT_RESPONSE_TEXT); response = Response - .status(Response.Status.OK) - .entity(responseText) - .build(); + .status(Response.Status.OK) + .entity(responseText) + .build(); return response; case "Checkin": - action = actionManager.checkin(actionInvariantUuId, user); + action = actionManager.checkin(invariantUUID, user); break; case "Submit": - action = actionManager.submit(actionInvariantUuId, user); + action = actionManager.submit(invariantUUID, user); break; default: throw new ActionException(ACTION_INVALID_PARAM_CODE, - String.format(ACTION_UNSUPPORTED_OPERATION, status)); + String.format(ACTION_UNSUPPORTED_OPERATION, status)); } - ActionResponseDto actionResponseDto = new ActionResponseDto(); - new MapActionToActionResponseDto().doMapping(action, actionResponseDto); - response = Response.ok(actionResponseDto).build(); - actionLogPostProcessor(StatusCode.COMPLETE,true); - }catch (ActionException e){ - actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + ActionResponseDto actionResponseDTO = new ActionResponseDto(); + new MapActionToActionResponseDto().doMapping(action, actionResponseDTO); + response = Response.ok(actionResponseDTO).build(); + actionLogPostProcessor(StatusCode.COMPLETE, true); + } catch (ActionException exception) { + actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); log.error(MDC.get(ERROR_DESCRIPTION)); - throw e; - }catch (Exception e){ - actionLogPostProcessor(StatusCode.ERROR,true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(e.getMessage()); - throw e; - }finally { + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(StatusCode.ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, + ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(exception.getMessage()); + throw exception; + } finally { finalAuditMetricsLogProcessor(ActionRequest.ACTION_VERSIONING.name()); - log.debug("exit actOnAction with invariantUUID= "+ actionInvariantUuId + " and requestJSON= "+ requestJson ); + log.debug("exit actOnAction with invariantUUID= " + invariantUUID + " and requestJSON= " + + requestJSON); } return response; } @Override - public Response uploadArtifact(String actionInvariantUuId, + public Response uploadArtifact(String actionInvariantUUID, String artifactName, String artifactLabel, String artifactCategory, @@ -612,88 +570,95 @@ public class ActionsImpl implements Actions { HttpServletRequest servletRequest) { Response response = null; try { - initializeRequestMDC(servletRequest,actionInvariantUuId, ActionRequest.UPLOAD_ARTIFACT); - log.debug("entering uploadArtifact with actionInvariantUUID= "+ actionInvariantUuId + "artifactName= "+ artifactName ); - response = uploadArtifactInternal(actionInvariantUuId, artifactName, artifactLabel, artifactCategory, artifactDescription, artifactProtection, checksum, artifactToUpload, servletRequest); - actionLogPostProcessor(StatusCode.COMPLETE,true); - log.debug("exiting uploadArtifact with actionInvariantUUID= "+ actionInvariantUuId + "artifactName= "+ artifactName ); - }catch (ActionException e){ - actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + initializeRequestMDC(servletRequest, actionInvariantUUID, ActionRequest.UPLOAD_ARTIFACT); + log.debug("entering uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + + "artifactName= " + artifactName); + response = + uploadArtifactInternal(actionInvariantUUID, artifactName, artifactLabel, artifactCategory, + artifactDescription, artifactProtection, checksum, artifactToUpload, servletRequest); + actionLogPostProcessor(StatusCode.COMPLETE, true); + log.debug("exiting uploadArtifact with actionInvariantUuId= " + actionInvariantUUID + + "artifactName= " + artifactName); + } catch (ActionException exception) { + actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); log.error(MDC.get(ERROR_DESCRIPTION)); - throw e; - }catch (Exception e){ - actionLogPostProcessor(StatusCode.ERROR,true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(e.getMessage()); - throw e; - }finally { + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(StatusCode.ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, + ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(exception.getMessage()); + throw exception; + } finally { finalAuditMetricsLogProcessor(ActionRequest.UPLOAD_ARTIFACT.name()); } - log.debug("exiting uploadArtifact with actionInvariantUUID= "+ actionInvariantUuId + "artifactName= "+ artifactName ); + log.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, + private Response uploadArtifactInternal(String actionInvariantUUID, String artifactName, + String artifactLabel, String artifactCategory, + String artifactDescription, String artifactProtection, + String checksum, Attachment artifactToUpload, HttpServletRequest servletRequest) { ListResponseWrapper responseList = null; 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{ + 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)){ + 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)){ + 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); + if (artifactToUpload == null) { + throw new ActionException(ACTION_REQUEST_INVALID_GENERIC_CODE, + ACTION_REQUEST_MISSING_MANDATORY_PARAM + ARTIFACT_FILE); } InputStream artifactInputStream = null; try { artifactInputStream = artifactToUpload.getDataHandler().getInputStream(); - } catch (IOException e) { + } catch (IOException exception) { throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ARTIFACT_READ_FILE_ERROR); } payload = FileUtils.toByteArray(artifactInputStream); //Validate Artifact size - if(payload != null && payload.length > MAX_ACTION_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))){ + 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)) + 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); + 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()){ + if (errorMap.isEmpty()) { String user = servletRequest.getRemoteUser(); ActionArtifact upload = new ActionArtifact(); upload.setArtifactName(artifactName); @@ -702,93 +667,100 @@ public class ActionsImpl implements Actions { upload.setArtifact(payload); upload.setArtifactCategory(artifactCategory); upload.setArtifactProtection(artifactProtection); - uploadedArtifact = actionManager.uploadArtifact(upload, actionInvariantUuId, user); - } - else{ + uploadedArtifact = actionManager.uploadArtifact(upload, actionInvariantUUID, user); + } else { checkAndThrowError(errorMap); } return Response.ok(uploadedArtifact).build(); } @Override - public Response downloadArtifact(String actionUuId, String artifactUuId, + public Response downloadArtifact(String actionUUID, String artifactUUID, HttpServletRequest servletRequest) { Response response = null; try { initializeRequestMDC(servletRequest, "", ActionRequest.DOWNLOAD_ARTIFACT); - log.debug(" entering downloadArtifact with actionUUID= " + actionUuId + " and artifactUUID= " + artifactUuId); - response = downloadArtifactInternal(actionUuId, artifactUuId, servletRequest); + log.debug( + " entering downloadArtifact with actionUUID= " + actionUUID + " and artifactUUID= " + + artifactUUID); + response = downloadArtifactInternal(actionUUID, artifactUUID, servletRequest); actionLogPostProcessor(StatusCode.COMPLETE, true); - }catch (ActionException e){ - actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + } catch (ActionException exception) { + actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); log.error(MDC.get(ERROR_DESCRIPTION)); - throw e; - }catch (Exception e){ - actionLogPostProcessor(StatusCode.ERROR,true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(e.getMessage()); - throw e; - }finally { + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(StatusCode.ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, + ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(exception.getMessage()); + throw exception; + } finally { finalAuditMetricsLogProcessor(ActionRequest.DOWNLOAD_ARTIFACT.name()); } - log.debug(" exit downloadArtifact with actionUUID= " + actionUuId + " and artifactUUID= " + artifactUuId); + log.debug(" exit downloadArtifact with actionUUID= " + actionUUID + " and artifactUUID= " + + artifactUUID); return response; } - public Response downloadArtifactInternal(String actionUuId, String artifactUuId, - HttpServletRequest servletRequest) { + 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); + Map<String, String> queryParamErrors = validateQueryParam(actionUUID); errorMap.putAll(queryParamErrors); - queryParamErrors = validateQueryParam(artifactUuId); + queryParamErrors = validateQueryParam(artifactUUID); errorMap.putAll(queryParamErrors); if (errorMap.isEmpty()) { - actionartifact = actionManager.downloadArtifact(actionUuId, artifactUuId); + actionartifact = actionManager.downloadArtifact(actionUUID, artifactUUID); } else { checkAndThrowError(errorMap); } - - return createArtifactDownloadResponse(actionartifact); + response = createArtifactDownloadResponse(actionartifact); + return response; } @Override - public Response deleteArtifact(String actionInvariantUuId, String artifactUuId, + public Response deleteArtifact(String actionInvariantUUID, String artifactUUID, HttpServletRequest servletRequest) { - Response response=null; + Response response = null; try { - initializeRequestMDC(servletRequest, actionInvariantUuId, ActionRequest.DELETE_ARTIFACT); - log.debug(" entering deleteArtifact with actionInvariantUUID= " + actionInvariantUuId + " and artifactUUID= " + artifactUuId); - response = deleteArtifactInternal(actionInvariantUuId, artifactUuId, servletRequest); - log.debug(" exit deleteArtifact with actionInvariantUUID= " + actionInvariantUuId + " and artifactUUID= " + artifactUuId); + initializeRequestMDC(servletRequest, actionInvariantUUID, ActionRequest.DELETE_ARTIFACT); + log.debug(" entering deleteArtifact with actionInvariantUuId= " + actionInvariantUUID + + " and artifactUUID= " + artifactUUID); + response = deleteArtifactInternal(actionInvariantUUID, artifactUUID, servletRequest); + log.debug(" exit deleteArtifact with actionInvariantUuId= " + actionInvariantUUID + + " and artifactUUID= " + artifactUUID); actionLogPostProcessor(StatusCode.COMPLETE, true); - }catch (ActionException e){ - actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + } catch (ActionException exception) { + actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); log.error(MDC.get(ERROR_DESCRIPTION)); - throw e; - }catch (Exception e){ - actionLogPostProcessor(StatusCode.ERROR,true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(e.getMessage()); - throw e; - }finally { + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(StatusCode.ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, + ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(exception.getMessage()); + throw exception; + } finally { finalAuditMetricsLogProcessor(ActionRequest.DELETE_ARTIFACT.name()); } return response; } - public Response deleteArtifactInternal(String actionInvariantUuId, String artifactUuId, - HttpServletRequest servletRequest) { + private Response deleteArtifactInternal(String actionInvariantUUID, String artifactUUID, + HttpServletRequest servletRequest) { Map<String, String> errorMap = validateRequestHeaders(servletRequest); - Map<String, String> queryParamErrors = validateQueryParam(actionInvariantUuId); + Map<String, String> queryParamErrors = validateQueryParam(actionInvariantUUID); errorMap.putAll(queryParamErrors); - queryParamErrors = validateQueryParam(artifactUuId); + queryParamErrors = validateQueryParam(artifactUUID); errorMap.putAll(queryParamErrors); if (errorMap.isEmpty()) { actionManager - .deleteArtifact(actionInvariantUuId, artifactUuId, servletRequest.getRemoteUser()); + .deleteArtifact(actionInvariantUUID, artifactUUID, servletRequest.getRemoteUser()); } else { checkAndThrowError(errorMap); } @@ -796,41 +768,62 @@ public class ActionsImpl implements Actions { } @Override - public Response updateArtifact(String actionInvariantUuId, String artifactUuId, + 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; - log.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); + Response response = null; + log.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); + initializeRequestMDC(servletRequest, actionInvariantUUID, ActionRequest.UPDATE_ARTIFACT); + response = + updateArtifactInternal(actionInvariantUUID, artifactUUID, artifactName, artifactLabel, + artifactCategory, artifactDescription, artifactProtection, checksum, artifactToUpdate, + servletRequest); actionLogPostProcessor(StatusCode.COMPLETE, true); - }catch (ActionException e){ - actionLogPostProcessor(StatusCode.ERROR, e.getErrorCode(), e.getDescription(), true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, e.getErrorCode(), e.getDescription()); + } catch (ActionException exception) { + actionLogPostProcessor(StatusCode.ERROR, exception.getErrorCode(), exception.getDescription(), true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, exception.getErrorCode(), exception.getDescription()); log.error(MDC.get(ERROR_DESCRIPTION)); - throw e; - }catch (Exception e){ - actionLogPostProcessor(StatusCode.ERROR,true); - actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); - log.error(e.getMessage()); - throw e; - }finally { + throw exception; + } catch (Exception exception) { + actionLogPostProcessor(StatusCode.ERROR, true); + actionErrorLogProcessor(CategoryLogLevel.ERROR, ACTION_INTERNAL_SERVER_ERR_CODE, + ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + log.error(exception.getMessage()); + throw exception; + } finally { finalAuditMetricsLogProcessor(ActionRequest.UPDATE_ARTIFACT.name()); } - log.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); + log.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; } - public Response updateArtifactInternal(String actionInvariantUuId, String artifactUuId, - String artifactName, String artifactLabel, String artifactCategory, - String artifactDescription, String artifactProtection, - String checksum, Attachment artifactToUpdate, - HttpServletRequest servletRequest) { + private void finalAuditMetricsLogProcessor(String targetServiceName) { + MDC.put(TARGET_SERVICE_NAME, targetServiceName); + MDC.put(TARGET_ENTITY, TARGET_ENTITY_API); + log.metrics(""); + log.audit(""); + } + + 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)) { @@ -841,7 +834,7 @@ public class ActionsImpl implements Actions { InputStream artifactInputStream = null; try { artifactInputStream = artifactToUpdate.getDataHandler().getInputStream(); - } catch (IOException e) { + } catch (IOException exception) { throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, ACTION_ARTIFACT_READ_FILE_ERROR); } @@ -849,7 +842,7 @@ public class ActionsImpl implements Actions { //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); + ACTION_ARTIFACT_TOO_BIG_ERROR); } //Validate Checksum @@ -859,29 +852,28 @@ public class ActionsImpl implements Actions { } if (artifactProtection != null && (artifactProtection.isEmpty() || - (!artifactProtection.equals(ActionArtifactProtection.readOnly.name()) && - !artifactProtection.equals(ActionArtifactProtection.readWrite.name())))) { + (!artifactProtection.equals(ActionArtifactProtection.readOnly.name()) && + !artifactProtection.equals(ActionArtifactProtection.readWrite.name())))) { errorMap.put(ACTION_ARTIFACT_INVALID_PROTECTION_CODE, - ACTION_REQUEST_ARTIFACT_INVALID_PROTECTION_VALUE); + 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.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); + actionManager.updateArtifact(update, actionInvariantUUID, user); } else { checkAndThrowError(errorMap); } return Response.ok().build(); - //return Response.status(Response.Status.OK).entity("Artifact successfully updated").build(); } /** @@ -901,10 +893,10 @@ public class ActionsImpl implements Actions { } /** - * Get Actions by ECOMP component ID + * Get Actions by OPENECOMP component ID */ - private Response getActionsByECOMPComponent(String componentID, - HttpServletRequest servletRequest) { + private Response getActionsByOpenEcompComponents(String componentID, + HttpServletRequest servletRequest) { ListResponseWrapper responseList = null; Map<String, String> errorMap = validateRequestHeaders(servletRequest); ; @@ -912,7 +904,7 @@ public class ActionsImpl implements Actions { errorMap.putAll(queryParamErrors); if (errorMap.isEmpty()) { List<Action> actions = - actionManager.getFilteredActions(FILTER_TYPE_ECOMP_COMPONENT, componentID); + actionManager.getFilteredActions(FILTER_TYPE_OPEN_ECOMP_COMPONENT, componentID); responseList = createResponse(actions); } else { checkAndThrowError(errorMap); @@ -959,8 +951,11 @@ public class ActionsImpl implements Actions { */ private Response getActionsByUniqueID(String actionUUID, HttpServletRequest servletRequest, String actionInvariantUUID) { - Map<String, String> errorMap = validateRequestHeaders(servletRequest); + log.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()) { @@ -969,7 +964,7 @@ public class ActionsImpl implements Actions { 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(TIMESTAMP, getUtcDateStringFromTimestamp(action.getTimestamp())); responseDTO.put(UPDATED_BY, action.getUser()); } else { throw new ActionException(ACTION_ENTITY_NOT_EXIST_CODE, ACTION_ENTITY_NOT_EXIST); @@ -977,6 +972,9 @@ public class ActionsImpl implements Actions { } else { checkAndThrowError(errorMap); } + log.debug( + " exit getActionByUUID with invariantID= " + actionInvariantUUID + " and actionUUID= " + + actionUUID); return Response.ok(responseDTO).build(); } @@ -1025,14 +1023,14 @@ public class ActionsImpl implements Actions { private Map<String, String> validateRequestHeaders(HttpServletRequest servletRequest) { Map<String, String> errorMap = new LinkedHashMap<>(); //Syntactic generic request parameter validations - String ecompRequestId = servletRequest.getHeader(X_ECOMP_REQUEST_ID_HEADER_PARAM); - if (StringUtils.isEmpty(ecompRequestId)) { - errorMap.put(ACTION_INVALID_REQUEST_ID_CODE, ACTION_REQUEST_ECOMP_REQUEST_ID_INVALID); + 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 ecompInstanceId = servletRequest.getHeader(X_ECOMP_INSTANCE_ID_HEADER_PARAM); - if (StringUtils.isEmpty(ecompInstanceId)) { - errorMap.put(ACTION_INVALID_INSTANCE_ID_CODE, ACTION_REQUEST_ECOMP_INSTANCE_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; } @@ -1064,8 +1062,8 @@ public class ActionsImpl implements Actions { requestBodyErrorMap.put(ACTION_INVALID_REQUEST_BODY_CODE, ACTION_REQUEST_BODY_EMPTY); } else { switch (requestType) { - case REQUEST_TYPE_CREATE_ACTION: - case REQUEST_TYPE_UPDATE_ACTION: + case ActionConstants.REQUEST_TYPE_CREATE_ACTION: + case ActionConstants.REQUEST_TYPE_UPDATE_ACTION: //Semantic request specific validations Action action = JsonUtil.json2Object(requestJSON, Action.class); if (StringUtils.isEmpty(action.getName())) { @@ -1079,10 +1077,6 @@ public class ActionsImpl implements Actions { } } - if (StringUtils.isEmpty(action.getEndpointUri())) { - setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, ACTION_REQUEST_PARAM_END_POINT_URI, - requestBodyErrorMap); - } if (action.getSupportedModels() != null && !isIDPresentInMap(action.getSupportedModels(), SUPPORTED_MODELS_VERSION_ID)) { setErrorValue(ACTION_REQUEST_INVALID_GENERIC_CODE, @@ -1136,8 +1130,8 @@ public class ActionsImpl implements Actions { } /** - * @throws ActionException if given ErrorMap is not empty. - * All error messages at given time are thrown in one single exception + * @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) { @@ -1158,7 +1152,7 @@ public class ActionsImpl implements Actions { String data = action.getData(); ActionResponseDto responseDTO = JsonUtil.json2Object(data, ActionResponseDto.class); responseDTO.setStatus(action.getStatus().name()); - responseDTO.setTimestamp(getUTCDateStringFromTimestamp(action.getTimestamp())); + responseDTO.setTimestamp(getUtcDateStringFromTimestamp(action.getTimestamp())); //if(!action.getUser().equals(DELETE_ACTION_USER)) responseDTO.setUpdatedBy(action.getUser()); return responseDTO; @@ -1185,9 +1179,9 @@ public class ActionsImpl implements Actions { FileOutputStream fos = new FileOutputStream(artifactFile); fos.write(artifactsBytes); fos.close(); - } catch (IOException e) { - throw new ActionException(ACTION_INTERNAL_SERVER_ERR_CODE, - ACTION_ENTITY_INTERNAL_SERVER_ERROR_MSG); + } catch (IOException 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", @@ -1201,6 +1195,37 @@ public class ActionsImpl implements Actions { } } + /** + * 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, StatusCode.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 (log.isDebugEnabled()) { + MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.DEBUG.name()); + } else if (log.isInfoEnabled()) { + MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.INFO.name()); + } else if (log.isWarnEnabled()) { + MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.WARN.name()); + } else if (log.isErrorEnabled()) { + MDC.put(CATEGORY_LOG_LEVEL, CategoryLogLevel.ERROR.name()); + } + } + private String CalcMD5CheckSum(byte[] input) { String checksum = null; if (input != null) { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml index dfb6c38e4c..2ac95764f6 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml @@ -3,6 +3,10 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + + <artifactId>action-library-rest-types</artifactId> + <name>action-library-rest-types</name> + <parent> <groupId>org.openecomp.sdc.onboarding</groupId> <artifactId>action-library-rest</artifactId> @@ -10,11 +14,6 @@ <relativePath>../</relativePath> </parent> - <artifactId>action-library-rest-types</artifactId> - <name>action-library-rest-types</name> - - - <dependencies> <dependency> <groupId>org.openecomp.sdc</groupId> @@ -34,4 +33,4 @@ </dependencies> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml.versionsBackup new file mode 100644 index 0000000000..4749ce7f8c --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-types/pom.xml.versionsBackup @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>action-library-rest-types</artifactId> + <name>action-library-rest-types</name> + + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>action-library-rest</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-action-api</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <!--<dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-license-manager</artifactId> + <version>${project.version}</version> + </dependency>--> + </dependencies> + + +</project>
\ No newline at end of file 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 1b3a5cb445..0632cabaa1 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 @@ -20,9 +20,6 @@ package org.openecomp.sdcrests.action.types; -/** - * Defines DTO for capturing input for versioning operations. - */ 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 0ae8504db5..7d7a4b3106 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 @@ -20,19 +20,19 @@ package org.openecomp.sdcrests.action.types; -import org.openecomp.sdc.action.types.EcompComponent; +import org.openecomp.sdc.action.types.OpenEcompComponent; import java.util.ArrayList; import java.util.List; /** - * Defines DTO used for creating Response with list of {@link ActionResponseDto } - * or list of {@link EcompComponent }. + * Defines DTO used for creating Response with list of {@link ActionResponseDto } or list of {@link + * openEcompComponent }. */ public class ListResponseWrapper { List<ActionResponseDto> actionList; - List<EcompComponent> componentList; + List<OpenEcompComponent> componentList; List<ActionResponseDto> versions; @@ -56,15 +56,15 @@ public class ListResponseWrapper { this.actionList = actionList; } - public List<EcompComponent> getComponentList() { + public List<OpenEcompComponent> getComponentList() { return componentList; } - public void setComponentList(List<EcompComponent> componentList) { + public void setComponentList(List<OpenEcompComponent> componentList) { this.componentList = componentList; } - public void add(ActionResponseDto e0) { - this.getActionList().add(e0); + public void add(ActionResponseDto exception) { + this.getActionList().add(exception); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml index 359b2b7f29..c0ce1ee577 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml @@ -3,20 +3,19 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>action-library-rest</artifactId> + <name>action-library-rest</name> + <packaging>pom</packaging> + <parent> <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-rest-webapp</artifactId> <version>1.1.0-SNAPSHOT</version> <relativePath>../</relativePath> </parent> - <groupId>org.openecomp.sdc.onboarding</groupId> - <artifactId>action-library-rest</artifactId> - <name>action-library-rest</name> - <packaging>pom</packaging> - - <modules> <module>/action-library-rest-services</module> <module>/action-library-rest-types</module> </modules> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml.versionsBackup new file mode 100644 index 0000000000..de6c4c6760 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/pom.xml.versionsBackup @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>action-library-rest</artifactId> + <name>action-library-rest</name> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + <modules> + <module>/action-library-rest-services</module> + <module>/action-library-rest-types</module> + </modules> +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml new file mode 100644 index 0000000000..baa9fdfc2b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/pom.xml @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>activity-log-rest-services</artifactId> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>activity-log-rest</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <dependencies> + + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>1</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-activity-log-manager</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>activity-log-rest-types</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>${project.version}</version> + </dependency> + <!-- CXF --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + + </dependencies> + + +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/ActivityLog.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/ActivityLog.java new file mode 100644 index 0000000000..be4cc1bbf5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/ActivityLog.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.activitylog.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.openecomp.sdcrests.activitylog.types.ActivityLogDto; +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/activity-logs") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Item Activity Log") +@Validated +public interface ActivityLog { + + @GET + @Path("/{itemId}/versions/{versionId}") + @ApiOperation(value = "List actions log of item", + response = ActivityLogDto.class, + responseContainer = "List") + Response getActivityLog(@ApiParam("Item Id") @PathParam("itemId") String itemId, + @ApiParam("Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/mapping/MapActivityLogEntityToActivityLogDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/mapping/MapActivityLogEntityToActivityLogDto.java new file mode 100644 index 0000000000..2794315188 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/mapping/MapActivityLogEntityToActivityLogDto.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.activitylog.rest.mapping; + +import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; +import org.openecomp.sdcrests.activitylog.types.ActivityLogDto; +import org.openecomp.sdcrests.activitylog.types.ActivityStatus; +import org.openecomp.sdcrests.activitylog.types.ActivityType; +import org.openecomp.sdcrests.mapping.MappingBase; + +public class MapActivityLogEntityToActivityLogDto extends MappingBase<ActivityLogEntity, ActivityLogDto> { + + + @Override + public void doMapping(ActivityLogEntity source, ActivityLogDto target) { + target.setId(source.getId()); + target.setTimestamp(source.getTimestamp()); + target.setType(source.getType()); + 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/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/services/ActivityLogImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/services/ActivityLogImpl.java new file mode 100644 index 0000000000..c42d72b7a5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-services/src/main/java/org/openecomp/sdcrests/activitylog/rest/services/ActivityLogImpl.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.activitylog.rest.services; + +import org.openecomp.sdc.activityLog.ActivityLogManager; +import org.openecomp.sdc.activityLog.ActivityLogManagerFactory; +import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.activitylog.rest.ActivityLog; +import org.openecomp.sdcrests.activitylog.rest.mapping.MapActivityLogEntityToActivityLogDto; +import org.openecomp.sdcrests.activitylog.types.ActivityLogDto; +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("activityLog") +@Scope(value = "prototype") +public class ActivityLogImpl implements ActivityLog { + + private ActivityLogManager activityLogManager = + ActivityLogManagerFactory.getInstance().createInterface(); + + + @Override + public Response getActivityLog(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_List_Activity_Log.toString()); + + Collection<ActivityLogEntity> activityLogs = + activityLogManager.listActivityLogs(vspId, Version.valueOf(versionId), user); + + MapActivityLogEntityToActivityLogDto mapper = new MapActivityLogEntityToActivityLogDto(); + GenericCollectionWrapper<ActivityLogDto> results = new GenericCollectionWrapper<>(); + for (ActivityLogEntity activityLog : activityLogs) { + results.add(mapper.applyMapping(activityLog, ActivityLogDto.class)); + } + + return Response.ok(results).build(); + } +} + diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/pom.xml new file mode 100644 index 0000000000..6139f04369 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/pom.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>activity-log-rest-types</artifactId> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>activity-log-rest</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityLogDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityLogDto.java new file mode 100644 index 0000000000..dde579554f --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityLogDto.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.activitylog.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; + + public ActivityLogDto(){} + + public String getId() { return id; } + + public void setId(String id) { this.id = id; } + + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public String getUser() { + return user; + } + + public void setUser(String user) { + this.user = user; + } + + public ActivityStatus getStatus() { + return status; + } + + public void setStatus(ActivityStatus status) { + this.status = status; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityStatus.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityStatus.java new file mode 100644 index 0000000000..326b1b624d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityStatus.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.openecomp.sdcrests.activitylog.types; + +public class ActivityStatus { + + private boolean success; + private String message; + + public ActivityStatus() { + } + + public ActivityStatus(boolean success) { + this(success, null); + } + + public ActivityStatus(boolean success, String message) { + this.success = success; + this.message = message; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java new file mode 100644 index 0000000000..dcbad726ab --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/activity-log-rest-types/src/main/java/org/openecomp/sdcrests/activitylog/types/ActivityType.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.activitylog.types; + +import java.io.Serializable; + +public enum ActivityType implements Serializable { + + CREATE_NEW("Create New"), + CHECKOUT("Check Out"), + CHECKIN("Check In"), + UPLOAD_HEAT("Upload Heat"), + UPLOAD_ARTIFACT("Upload Artifact"), + SUBMIT("Submit"); + + // after collaboration will be added - this will be added: + /* + CREATE_NEW, + COMMIT, + ADD_PERMISSION, + REMOVE_PERMISSION, + */ + + private String name; + + ActivityType(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml new file mode 100644 index 0000000000..cb096cdd30 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/activity-log-rest/pom.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.openecomp.sdc</groupId> + <artifactId>activity-log-rest</artifactId> + <packaging>pom</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <modules> + <module>activity-log-rest-services</module> + <module>activity-log-rest-types</module> + </modules> + +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml index de45b5a0e8..1c99280735 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml @@ -4,21 +4,20 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <artifactId>application-config-rest-services</artifactId> + <parent> <groupId>org.openecomp.sdc</groupId> <artifactId>application-config-rest</artifactId> <version>1.1.0-SNAPSHOT</version> </parent> - <artifactId>application-config-rest-services</artifactId> - <!--packaging>pom</packaging--> - <dependencies> <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-annotations</artifactId> - <version>1.5.3</version> + <version>${swagger.version}</version> </dependency> <dependency> <groupId>javax.ws.rs</groupId> @@ -33,7 +32,7 @@ <dependency> <groupId>javax.inject</groupId> <artifactId>javax.inject</artifactId> - <version>1</version> + <version>${javax.inject.version}</version> </dependency> <dependency> <groupId>org.openecomp.sdc</groupId> @@ -59,4 +58,4 @@ </dependencies> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml.versionsBackup new file mode 100644 index 0000000000..9c3472a970 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-services/pom.xml.versionsBackup @@ -0,0 +1,63 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <artifactId>application-config-rest-services</artifactId> + <version>1.0-SNAPSHOT</version> + <!--packaging>pom</packaging--> + + <dependencies> + + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>1.5.3</version> + </dependency> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>1</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-application-config-manager</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest-types</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <!-- CXF --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + </dependencies> + + +</project>
\ No newline at end of file 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 df743a6a93..6c95a14319 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 @@ -37,7 +37,6 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - @Path("/v1.0/application-configuration") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) 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 4d43e37769..4ced6ba302 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 @@ -24,6 +24,9 @@ import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfig import org.openecomp.sdcrests.applicationconfiguration.types.ApplicationConfigDto; import org.openecomp.sdcrests.mapping.MappingBase; +/** + * Created by Talio on 8/10/2016. + */ public class MapApplicationConfigEntityToApplicationConfigDto extends MappingBase<ApplicationConfigEntity, ApplicationConfigDto> { @Override 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 6865c676ec..c86628d301 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 @@ -24,6 +24,9 @@ import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData; import org.openecomp.sdcrests.applicationconfiguration.types.ConfigurationDataDto; import org.openecomp.sdcrests.mapping.MappingBase; +/** + * Created by Talio on 8/9/2016. + */ public class MapConfigurationDataToConfigurationDataDto extends MappingBase<ConfigurationData, ConfigurationDataDto> { @Override 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 81f7251fdc..4ffe4488da 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 @@ -24,13 +24,17 @@ import org.openecomp.core.utilities.applicationconfig.dao.type.ApplicationConfig import org.openecomp.core.utilities.applicationconfig.type.ConfigurationData; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.applicationconfig.ApplicationConfigManager; +import org.openecomp.sdc.common.utils.CommonUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdcrests.applicationconfig.rest.ApplicationConfiguration; import org.openecomp.sdcrests.applicationconfig.rest.mapping.MapApplicationConfigEntityToApplicationConfigDto; import org.openecomp.sdcrests.applicationconfig.rest.mapping.MapConfigurationDataToConfigurationDataDto; import org.openecomp.sdcrests.applicationconfiguration.types.ApplicationConfigDto; import org.openecomp.sdcrests.applicationconfiguration.types.ConfigurationDataDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; - +import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; @@ -38,38 +42,59 @@ import org.springframework.stereotype.Service; import java.io.InputStream; import java.util.Collection; import javax.inject.Named; - import javax.ws.rs.core.Response; +/** + * Created by Talio on 8/8/2016. + */ + @Named @Service("applicationConfiguration") @Scope(value = "prototype") public class ApplicationConfigurationImpl implements ApplicationConfiguration { + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); @Autowired private ApplicationConfigManager applicationConfigManager; - @Override public Response insertToTable(String namespace, String key, InputStream fileContainingSchema) { + + mdcDataDebugMessage.debugEntryMessage(null, null); + + MDC.put(LoggerConstants.SERVICE_NAME, + LoggerServiceName.Insert_To_ApplicationConfig_Table.toString()); String value = new String(FileUtils.toByteArray(fileContainingSchema)); applicationConfigManager.insertIntoTable(namespace, key, value); + mdcDataDebugMessage.debugExitMessage(null, null); return Response.ok().build(); } @Override public Response getFromTable(String namespace, String key) { + + mdcDataDebugMessage.debugEntryMessage(null, null); + + MDC.put(LoggerConstants.SERVICE_NAME, + LoggerServiceName.Get_From_ApplicationConfig_Table.toString()); ConfigurationData value = applicationConfigManager.getFromTable(namespace, key); ConfigurationDataDto valueDto = new MapConfigurationDataToConfigurationDataDto() .applyMapping(value, ConfigurationDataDto.class); + mdcDataDebugMessage.debugExitMessage(null, null); + return Response.ok(valueDto).build(); } @Override public Response getListOfConfigurationByNamespaceFromTable(String namespace) { + + mdcDataDebugMessage.debugEntryMessage(null, null); + + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName + .Get_List_From_ApplicationConfig_Table_By_Namespace.toString()); Collection<ApplicationConfigEntity> applicationConfigEntities = applicationConfigManager.getListOfConfigurationByNamespace(namespace); GenericCollectionWrapper<ApplicationConfigDto> applicationConfigWrapper = @@ -82,6 +107,8 @@ public class ApplicationConfigurationImpl implements ApplicationConfiguration { .add(mapper.applyMapping(applicationConfigEntity, ApplicationConfigDto.class)); } + mdcDataDebugMessage.debugExitMessage(null, null); + return Response.ok(applicationConfigWrapper).build(); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml index 6bc5ce9285..111d92d075 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml @@ -4,14 +4,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest-types</artifactId> + <parent> <groupId>org.openecomp.sdc</groupId> <artifactId>application-config-rest</artifactId> <version>1.1.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.sdc</groupId> - <artifactId>application-config-rest-types</artifactId> - - -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml.versionsBackup new file mode 100644 index 0000000000..a9c8bbaee5 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/application-config-rest-types/pom.xml.versionsBackup @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest-types</artifactId> + <version>1.0-SNAPSHOT</version> + + +</project>
\ No newline at end of file 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 4d2f160d51..787a191bd9 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 @@ -20,6 +20,9 @@ package org.openecomp.sdcrests.applicationconfiguration.types; +/** + * Created by Talio on 8/10/2016. + */ public class ApplicationConfigDto { private String key; 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 fcabcf5e89..2a523783ab 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 @@ -20,6 +20,9 @@ package org.openecomp.sdcrests.applicationconfiguration.types; +/** + * Created by Talio on 8/9/2016. + */ public class ConfigurationDataDto { private String value; private long timeStamp; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml index 565840a813..f00133dbc4 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml @@ -4,20 +4,19 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest</artifactId> + <packaging>pom</packaging> + <parent> <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-rest-webapp</artifactId> <version>1.1.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.sdc</groupId> - <artifactId>application-config-rest</artifactId> - <packaging>pom</packaging> - - <modules> <module>application-config-rest-services</module> <module>application-config-rest-types</module> </modules> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml.versionsBackup new file mode 100644 index 0000000000..fd2e251fea --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/application-config-rest/pom.xml.versionsBackup @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + + <modules> + <module>application-config-rest-services</module> + <module>application-config-rest-types</module> + </modules> + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml index fb98501012..db4b48600e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml @@ -1,184 +1,223 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-rest-webapp</artifactId> - <version>1.1.0-SNAPSHOT</version> - </parent> - <groupId>org.openecomp.sdc.onboarding</groupId> - <artifactId>onboarding-be</artifactId> - <name>onboarding-rest-war</name> - <packaging>war</packaging> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>onboarding-be</artifactId> + <name>onboarding-rest-war</name> + <packaging>war</packaging> + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> - - <dependencies> - <dependency> - <groupId>org.openecomp.sdc.onboarding</groupId> - <artifactId>vendor-license-rest-services</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc.onboarding</groupId> - <artifactId>vendor-software-products-rest-services</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc.onboarding</groupId> - <artifactId>validation-rest-services</artifactId> - <version>${project.version}</version> - </dependency> - <!--dependency> - <groupId>org.openecomp.sdc.onboarding</groupId> - <artifactId>application-config-rest-services</artifactId> - <version>${project.version}</version> - </dependency--> - <dependency> - <groupId>org.openecomp.sdc</groupId> - <artifactId>application-config-rest-services</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc.onboarding</groupId> - <artifactId>action-library-rest-services</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <version>${javax.servlet.version}</version> - </dependency> - <!-- JSON --> - <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-jaxrs</artifactId> - <version>${org.codehaus.jackson.version}</version> - </dependency> - <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-core-asl</artifactId> - <version>${org.codehaus.jackson.version}</version> - </dependency> - <dependency> - <groupId>javax.inject</groupId> - <artifactId>javax.inject</artifactId> - <version>1</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-servlets</artifactId> - <version>9.0.6.v20130930</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc</groupId> - <artifactId>openecomp-sdc-application-config-manager</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - <version>2.4.7</version> - </dependency> - <dependency> - <groupId>org.codehaus.janino</groupId> - <artifactId>janino</artifactId> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.codehaus.janino</groupId> - <artifactId>commons-compiler</artifactId> - <version>3.0.6</version> - <scope>compile</scope> - </dependency> + <dependencies> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-license-rest-services</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>activity-log-rest-services</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-software-products-rest-services</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>validation-rest-services</artifactId> + <version>${project.version}</version> + </dependency> + <!--dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>application-config-rest-services</artifactId> + <version>${project.version}</version> + </dependency--> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest-services</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>action-library-rest-services</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>${javax.servlet.version}</version> + </dependency> + <!-- JSON --> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-jaxrs</artifactId> + <version>${org.codehaus.jackson.version}</version> + </dependency> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-core-asl</artifactId> + <version>${org.codehaus.jackson.version}</version> + </dependency> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>${javax.inject.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlets</artifactId> + <version>${jetty.servlets.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-application-config-manager</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy</artifactId> + <version>${groovy.version}</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>${logback.version}</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>${logback.version}</version> + </dependency> + <dependency> + <groupId>org.codehaus.janino</groupId> + <artifactId>janino</artifactId> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring.framework.version}</version> + </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> - <version>4.1.3.RELEASE</version> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-aop</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-webmvc</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjweaver</artifactId> + <version>${aspectj.version}</version> + </dependency> + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjrt</artifactId> + <version>${aspectj.version}</version> + </dependency> + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjtools</artifactId> + <version>${aspectj.version}</version> </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - </plugin> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <includes> - <include>test/core/unittest/offline/**</include> - </includes> - <skipTests>true</skipTests> - <systemProperties> - <property> - <name>buildNumber</name> - <value>${buildNumber}</value> - </property> - </systemProperties> - </configuration> - </plugin> - <plugin> - <artifactId>maven-war-plugin</artifactId> - <version>2.1.1</version> - <configuration> - <attachClasses>true</attachClasses> - <webResources> - <resource> - <!-- this is relative to the pom.xml directory --> - <directory>${basedir}/target/generated/swagger-ui</directory> - </resource> - </webResources> - </configuration> - </plugin> - <plugin> - <groupId>com.github.kongchen</groupId> - <artifactId>swagger-maven-plugin</artifactId> - <version>3.1.0</version> - <configuration> - <apiSources> - <apiSource> - <springmvc>false</springmvc> - <locations>org.openecomp.sdcrests</locations> - <schemes>http</schemes> - <basePath>/onboarding-api</basePath> - <info> - <title>Rest API</title> - <version>v1.0, build #${buildNumber}</version> - <description>Rest API Documentation</description> - <termsOfService> - http://www.github.com/kongchen/swagger-maven-plugin - </termsOfService> - </info> - <templatePath>${basedir}/templates/strapdown.html.hbs</templatePath> - <outputPath>${basedir}/target/generated/api.html</outputPath> - <swaggerDirectory>${basedir}/target/generated/swagger-ui</swaggerDirectory> - </apiSource> - </apiSources> - </configuration> - <executions> - <execution> - <phase>compile</phase> - <goals> - <goal>generate</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>test/core/unittest/offline/**</include> + </includes> + <skipTests>true</skipTests> + <systemProperties> + <property> + <name>buildNumber</name> + <value>${buildNumber}</value> + </property> + </systemProperties> + </configuration> + </plugin> + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>${mvn.war.version}</version> + <configuration> + <attachClasses>true</attachClasses> + <webResources> + <resource> + <!-- this is relative to the pom.xml directory --> + <directory>${basedir}/target/generated/swagger-ui</directory> + </resource> + </webResources> + </configuration> + </plugin> + <plugin> + <groupId>com.github.kongchen</groupId> + <artifactId>swagger-maven-plugin</artifactId> + <version>${mvn.swagger.version}</version> + <configuration> + <apiSources> + <apiSource> + <springmvc>false</springmvc> + <locations>org.openecomp.sdcrests</locations> + <schemes>http</schemes> + <basePath>/onboarding-api</basePath> + <info> + <title>Rest API</title> + <version>v1.0, build #${buildNumber}</version> + <description>Rest API Documentation</description> + <termsOfService> + http://www.github.com/kongchen/swagger-maven-plugin + </termsOfService> + </info> + <templatePath>${basedir}/templates/strapdown.html.hbs</templatePath> + <outputPath>${basedir}/target/generated/api.html</outputPath> + <swaggerDirectory>${basedir}/target/generated/swagger-ui + </swaggerDirectory> + </apiSource> + </apiSources> + </configuration> + <executions> + <execution> + <phase>compile</phase> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> - <!--finalName>onboarding-api</finalName--> - </build> + <!--finalName>onboarding-api</finalName--> + </build> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml.versionsBackup new file mode 100644 index 0000000000..983518fd29 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/pom.xml.versionsBackup @@ -0,0 +1,226 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>onboarding-be</artifactId> + <name>onboarding-rest-war</name> + <version>1.0-SNAPSHOT</version> + <packaging>war</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-license-rest-services</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-software-products-rest-services</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>validation-rest-services</artifactId> + <version>${project.version}</version> + </dependency> + <!--dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>application-config-rest-services</artifactId> + <version>${project.version}</version> + </dependency--> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>application-config-rest-services</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>action-library-rest-services</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>${javax.servlet.version}</version> + </dependency> + <!-- JSON --> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-jaxrs</artifactId> + <version>${org.codehaus.jackson.version}</version> + </dependency> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-core-asl</artifactId> + <version>${org.codehaus.jackson.version}</version> + </dependency> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>1</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-servlets</artifactId> + <version>9.0.6.v20130930</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-application-config-manager</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy</artifactId> + <version>${groovy.version}</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>${logback.version}</version> + </dependency> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>${logback.version}</version> + </dependency> + <dependency> + <groupId>org.codehaus.janino</groupId> + <artifactId>janino</artifactId> + <scope>compile</scope> + </dependency> + <!--dependency> + <groupId>org.codehaus.janino</groupId> + <artifactId>commons-compiler</artifactId> + <version>3.0.6</version> + <scope>compile</scope> + </dependency--> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>4.1.3.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>4.1.3.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-aop</artifactId> + <version>4.1.3.RELEASE</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-webmvc</artifactId> + <version>4.1.3.RELEASE</version> + </dependency> + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjweaver</artifactId> + <version>1.8.9</version> + </dependency> + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjrt</artifactId> + <version>1.8.9</version> + </dependency> + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjtools</artifactId> + <version>1.8.9</version> + </dependency> + + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>test/core/unittest/offline/**</include> + </includes> + <skipTests>true</skipTests> + <systemProperties> + <property> + <name>buildNumber</name> + <value>${buildNumber}</value> + </property> + </systemProperties> + </configuration> + </plugin> + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>2.1.1</version> + <configuration> + <attachClasses>true</attachClasses> + <webResources> + <resource> + <!-- this is relative to the pom.xml directory --> + <directory>${basedir}/target/generated/swagger-ui</directory> + </resource> + </webResources> + </configuration> + </plugin> + <plugin> + <groupId>com.github.kongchen</groupId> + <artifactId>swagger-maven-plugin</artifactId> + <version>3.1.0</version> + <configuration> + <apiSources> + <apiSource> + <springmvc>false</springmvc> + <locations>org.openecomp.sdcrests</locations> + <schemes>http</schemes> + <basePath>/onboarding-api</basePath> + <info> + <title>Rest API</title> + <version>v1.0, build #${buildNumber}</version> + <description>Rest API Documentation</description> + <termsOfService> + http://www.github.com/kongchen/swagger-maven-plugin + </termsOfService> + </info> + <templatePath>${basedir}/templates/strapdown.html.hbs</templatePath> + <outputPath>${basedir}/target/generated/api.html</outputPath> + <swaggerDirectory>${basedir}/target/generated/swagger-ui + </swaggerDirectory> + </apiSource> + </apiSources> + </configuration> + <executions> + <execution> + <phase>compile</phase> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + + <!--finalName>onboarding-api</finalName--> + </build> + +</project>
\ No newline at end of file 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 6e9b4dbe25..e59d3fb3b8 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 @@ -23,7 +23,6 @@ package org.openecomp.server.filters; import java.io.IOException; import java.security.Principal; import java.util.Base64; - import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -40,6 +39,7 @@ public class ActionAuthenticationFilter implements Filter { @Override public void destroy() { + // TODO Auto-generated method stub } @@ -57,7 +57,7 @@ public class ActionAuthenticationFilter implements Filter { httpRequest.getHeader("Authorization").replace("Basic", "").trim(); String decodedCredentials = new String(Base64.getDecoder().decode(base64Credentials)); username = decodedCredentials.substring(0, decodedCredentials.indexOf(":")); - } catch (Exception e0) { + } catch (Exception exception) { setResponseStatus((HttpServletResponse) arg1, HttpServletResponse.SC_FORBIDDEN); return; } @@ -81,7 +81,7 @@ public class ActionAuthenticationFilter implements Filter { ActionLibraryPrivilege userPrivilege = ActionLibraryPrivilege .valueOf(username.substring(username.indexOf("-") + 1).toUpperCase()); return userPrivilege.ordinal() >= requiredPrivilege.ordinal(); - } catch (Exception e0) { + } catch (Exception exception) { return false; } } @@ -106,10 +106,7 @@ public class ActionAuthenticationFilter implements Filter { @Override public void init(FilterConfig arg0) throws ServletException { - /*runningOnLocal = System.getProperty("file.separator").equals("\\"); - if (!runningOnLocal){ - // call to super init of cadi filter as we are not running on windows - }*/ + } } 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 ba9c7537f4..82e4fa80d9 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 @@ -21,7 +21,6 @@ package org.openecomp.server.filters; import java.io.IOException; - import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -37,6 +36,8 @@ public class ActionAuthorizationFilter implements Filter { @Override public void destroy() { + // TODO Auto-generated method stub + } @Override @@ -62,10 +63,7 @@ public class ActionAuthorizationFilter implements Filter { @Override public void init(FilterConfig arg0) throws ServletException { - /*runningOnLocal = System.getProperty("file.separator").equals("\\"); - if (!runningOnLocal){ - // call to super init of cadi filter as we are not running on windows - }*/ + } } 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 c34af00830..6c8b1e8ca5 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 @@ -20,14 +20,30 @@ package org.openecomp.server.filters; +/** + * The enum Action library privilege. + */ public enum ActionLibraryPrivilege { - RETRIEVE, CREATE, UPDATE, 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 . - * @return actionLibraryPrivilege + * @param operation the operation + * @return the privilege */ public static ActionLibraryPrivilege getPrivilege(String operation) { 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 b2e1119a78..991a286a48 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 @@ -20,6 +20,7 @@ package org.openecomp.server.interceptors; + import java.io.Serializable; import java.lang.annotation.Annotation; import java.net.URI; @@ -48,6 +49,7 @@ public class DefaultOutput extends Response implements Serializable { this.status = s0; this.entity = e0; } + public Object getEntity() { return entity; } @@ -141,6 +143,7 @@ public class DefaultOutput extends Response implements Serializable { return false; } + @Override public Link getLink(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 4e2f56834f..9c02d5a558 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 @@ -29,6 +29,10 @@ 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 { 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 d2b24bde77..903907fa78 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 @@ -25,8 +25,7 @@ import org.codehaus.jackson.annotate.JsonAutoDetect; import java.io.Serializable; /** - * This class is for Internal use only. - * Please don't use this class. + * This class is for Internal use only. Please don't use this class. */ @JsonAutoDetect public class InternalEmptyObject implements Serializable { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml index 5eb2b98cd5..609d69f9f8 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/beans-services.xml @@ -7,6 +7,7 @@ http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> + <import resource="classpath:META-INF/cxf/cxf.xml"/> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> @@ -30,11 +31,27 @@ <!-- ASDC --> <bean id="vendorLicenseManager" class="org.openecomp.sdc.vendorlicense.impl.VendorLicenseManagerImpl"/> - <bean id="vendorSoftwareProductManager" class="org.openecomp.sdc.vendorsoftwareproduct.impl.VendorSoftwareProductManagerImpl"/> - <bean id="UploadValidationManager" class="org.openecomp.sdc.validation.impl.UploadValidationManagerImpl"/> + <bean id="uploadValidationManager" class="org.openecomp.sdc.validation.impl.UploadValidationManagerImpl"/> <bean id="actionManager" class="org.openecomp.sdc.action.impl.ActionManagerImpl"/> <bean id="applicationConfigManager" class="org.openecomp.sdc.applicationconfig.impl.ApplicationConfigManagerImpl"/> + <!-- aspect beans --> + <bean id = "debugAspect" class="org.openecomp.sdc.logging.aspects.DebugAspect"/> + + <!--aop:config> + < aspect pointcuts> + <aop:pointcut id="loggingDebugPointcut" expression="execution(* org.openecomp.sdc.*.*.*(..))"/> + + <advices> + <aop:aspect id="logDebugAspect" ref="debugAspect"> + <aop:before pointcut-ref="loggingDebugPointcut" method="debugEnterMethod"/> + <aop:after-returning pointcut-ref="loggingDebugPointcut" method="debugExitMethod"/> + </aop:aspect> + </aop:config--> + + + + <!-- RESTful Services --> <jaxrs:server id="restContainer" address="/"> @@ -54,6 +71,9 @@ <ref bean="actions"/> <ref bean="applicationConfiguration"/> <ref bean="componentUploads"/> + <ref bean="orchestrationTemplateCandidate"/> + <ref bean="componentDependencyModel"/> + <ref bean="activityLog"/> </jaxrs:serviceBeans> <jaxrs:providers> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml index 68b7758609..08e8dd8ec8 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/src/main/webapp/WEB-INF/web.xml @@ -1,20 +1,20 @@ -<!DOCTYPE web-app PUBLIC - "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" - "http://java.sun.com/dtd/web-app_2_3.dtd" > +<web-app + xmlns="http://java.sun.com/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + version="3.0"> -<web-app> + <!-- Spring --> + <context-param> + <param-name>contextConfigLocation</param-name> + <param-value>WEB-INF/beans-services.xml</param-value> + </context-param> - <!-- Spring --> - <context-param> - <param-name>contextConfigLocation</param-name> - <param-value>WEB-INF/beans-services.xml</param-value> - </context-param> - - <listener> - <listener-class>org.openecomp.server.listeners.OnboardingAppStartupListener</listener-class> - </listener> + <listener> + <listener-class>org.openecomp.server.listeners.OnboardingAppStartupListener</listener-class> + </listener> <filter> <filter-name>cross-origin</filter-name> @@ -55,41 +55,49 @@ </filter-mapping> <filter> <filter-name>LoggingServletFilter</filter-name> - <filter-class>org.openecomp.core.logging.servlet.LoggingFilter</filter-class> + <filter-class>org.openecomp.sdc.logging.servlet.LoggingFilter</filter-class> </filter> - <filter-mapping> - <filter-name>LoggingServletFilter</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> - <!-- CXF --> - <servlet> - <servlet-name>CXFServlet</servlet-name> - <display-name>CXF Servlet</display-name> - <servlet-class> - org.apache.cxf.transport.servlet.CXFServlet - </servlet-class> - <init-param> - <param-name>redirects-list</param-name> - <param-value> - /docs/(\S)+\.json - </param-value> - </init-param> - <init-param> - <param-name>redirect-attributes</param-name> - <param-value> - javax.servlet.include.request_uri - </param-value> - </init-param> - <init-param> - <param-name>redirect-servlet-name</param-name> - <param-value>default</param-value> - </init-param> - <load-on-startup>1</load-on-startup> - </servlet> - <servlet-mapping> - <servlet-name>CXFServlet</servlet-name> - <url-pattern>/*</url-pattern> - </servlet-mapping> + <filter-mapping> + <filter-name>LoggingServletFilter</filter-name> + <url-pattern>/*</url-pattern> + </filter-mapping> + <!-- CXF --> + <servlet> + <servlet-name>CXFServlet</servlet-name> + <display-name>CXF Servlet</display-name> + <servlet-class> + org.apache.cxf.transport.servlet.CXFServlet + </servlet-class> + <init-param> + <param-name>redirects-list</param-name> + <param-value> + /docs/(\S)+\.json + </param-value> + </init-param> + <init-param> + <param-name>redirect-attributes</param-name> + <param-value> + javax.servlet.include.request_uri + </param-value> + </init-param> + <init-param> + <param-name>redirect-servlet-name</param-name> + <param-value>default</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + <servlet-mapping> + <!--servlet-name>logger-aspect</servlet-name--> + <servlet-name>CXFServlet</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + <!--servlet> + <servlet-name>logger-aspect</servlet-name> + <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> + <load-on-startup>2</load-on-startup> + </servlet--> + + </web-app> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml index 07b7740d63..63cae56ef5 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml @@ -3,25 +3,22 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> - + <artifactId>openecomp-sdc-common-rest</artifactId> + <name>openecomp-sdc-common-rest</name> <parent> <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-rest-webapp</artifactId> <version>1.1.0-SNAPSHOT</version> </parent> - <artifactId>openecomp-sdc-common-rest</artifactId> - <name>openecomp-sdc-common-rest</name> - - <dependencies> <dependency> - <groupId>org.openecomp.sdc</groupId> + <groupId>org.openecomp.core</groupId> <artifactId>openecomp-utilities-lib</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>org.openecomp.sdc</groupId> + <groupId>org.openecomp.core</groupId> <artifactId>openecomp-common-lib</artifactId> <version>${project.version}</version> </dependency> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml.versionsBackup new file mode 100644 index 0000000000..aaf3383c42 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/pom.xml.versionsBackup @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <artifactId>openecomp-sdc-common-rest</artifactId> + <name>openecomp-sdc-common-rest</name> + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-utilities-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.core</groupId> + <artifactId>openecomp-common-lib</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-validator</artifactId> + <version>${hibernate.validator.version}</version> + </dependency> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + <!-- Swagger --> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-core</artifactId> + <version>${swagger.version}</version> + <scope>compile</scope> + </dependency> + </dependencies> + +</project>
\ No newline at end of file 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 499bd6e785..7bc1082ebe 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 @@ -21,7 +21,8 @@ package org.openecomp.sdcrests.common; public class RestConstants { - public static final String USER_HEADER_PARAM = "USER_ID"; + public static final String USER_ID_HEADER_PARAM = "USER_ID"; + // value Should be equal to com.tlv.sdc.common.api.Constants#USER_ID_HEADER 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 = diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/VersionDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/VersionDto.java new file mode 100644 index 0000000000..b5b86c65a2 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/openecomp-sdc-common-rest/src/main/java/org/openecomp/sdcrests/common/types/VersionDto.java @@ -0,0 +1,34 @@ +package org.openecomp.sdcrests.common.types; + +/** + * Created by SVISHNEV on 3/5/2017. + */ +public class VersionDto { + String id; + String label; + + public VersionDto(){ + + } + + public VersionDto(String id, String label) { + this.id = id; + this.label = label; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } +} 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 67da814f48..af77268599 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 @@ -22,6 +22,8 @@ package org.openecomp.sdcrests.errors; import org.codehaus.jackson.map.JsonMappingException; import org.hibernate.validator.internal.engine.path.PathImpl; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.core.utilities.CommonMethods; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.core.utilities.json.JsonUtil; @@ -32,8 +34,14 @@ import org.openecomp.sdc.common.errors.ErrorCodeAndMessage; import org.openecomp.sdc.common.errors.GeneralErrorBuilder; import org.openecomp.sdc.common.errors.JsonMappingErrorBuilder; import org.openecomp.sdc.common.errors.ValidationErrorBuilder; -import org.slf4j.LoggerFactory; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -42,8 +50,8 @@ 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 javax.ws.rs.core.Response; public class DefaultExceptionMapper implements ExceptionMapper<Exception> { private static final String ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE = @@ -51,23 +59,28 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> { private static Map<String, String> errorCodeToResponseStatus = JsonUtil .json2Object(FileUtils.getFileInputStream(ERROR_CODES_TO_RESPONSE_STATUS_MAPPING_FILE), Map.class); - private static org.slf4j.Logger logger = LoggerFactory.getLogger(DefaultExceptionMapper.class); + private static Logger logger = (Logger) LoggerFactory.getLogger(DefaultExceptionMapper.class); @Override - public Response toResponse(Exception e0) { + public Response toResponse(Exception exception) { Response response; - if (e0 instanceof CoreException) { - response = transform(CoreException.class.cast(e0)); - } else if (e0 instanceof ConstraintViolationException) { - response = transform(ConstraintViolationException.class.cast(e0)); + if (exception instanceof CoreException) { + response = transform(CoreException.class.cast(exception)); + } else if (exception instanceof ConstraintViolationException) { + response = transform(ConstraintViolationException.class.cast(exception)); - } else if (e0 instanceof JsonMappingException) { - response = transform(JsonMappingException.class.cast(e0)); + } else if (exception instanceof JsonMappingException) { + response = transform(JsonMappingException.class.cast(exception)); } else { - response = transform(e0); + response = transform(exception); } + try { + writeStackTraceToFile(exception); + } catch (IOException e) { + e.printStackTrace(); + } List<Object> contentTypes = new ArrayList<>(); contentTypes.add(MediaType.APPLICATION_JSON); response.getMetadata().put("Content-Type", contentTypes); @@ -133,7 +146,6 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> { .build(); } - private Response transform(JsonMappingException jsonMappingException) { ErrorCode jsonMappingErrorCode = new JsonMappingErrorBuilder().build(); logger.error(jsonMappingErrorCode.message(), jsonMappingException); @@ -143,9 +155,9 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> { .build(); } - private Response transform(Exception e0) { - ErrorCode generalErrorCode = new GeneralErrorBuilder(e0.getMessage()).build(); - logger.error(generalErrorCode.message(), e0); + private Response transform(Exception exception) { + ErrorCode generalErrorCode = new GeneralErrorBuilder(exception.getMessage()).build(); + logger.error(generalErrorCode.message(), exception); return Response .status(Response.Status.INTERNAL_SERVER_ERROR) .entity(toEntity(Response.Status.INTERNAL_SERVER_ERROR, generalErrorCode)) @@ -160,4 +172,17 @@ public class DefaultExceptionMapper implements ExceptionMapper<Exception> { return new ErrorCodeAndMessage(status, code); } + private void writeStackTraceToFile(Exception exception) throws IOException { + File file = new File("stack_trace.txt"); + OutputStream outputStream = new FileOutputStream(file); + + if(!file.exists()){ + file.createNewFile(); + } + + PrintWriter printWriter = new PrintWriter(file); + exception.printStackTrace(printWriter); + printWriter.close(); + } + } 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 7382ef72eb..6573485db7 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 @@ -22,20 +22,21 @@ package org.openecomp.sdcrests.mapping; /** * 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> + * 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. + * 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 @@ -64,10 +65,9 @@ public abstract class MappingBase<S, T> { } /** - * 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. + * 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. @@ -93,8 +93,8 @@ public abstract class MappingBase<S, T> { try { object = clazz.newInstance(); - } catch (InstantiationException | IllegalAccessException e0) { - //Do nothing + } catch (InstantiationException | IllegalAccessException exception) { + //TODO: what what? } return object; 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 b8d47e4ef3..22ce0a4e45 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 @@ -24,20 +24,12 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; -/** - * This class represents a generic collection wrapper to be used by paginated results. - * - * @param <T> the type parameter - */ public class GenericCollectionWrapper<T> implements Serializable { private static final long serialVersionUID = 1L; private List<T> results; private int listCount; - /** - * Instantiates a new Generic collection wrapper. - */ public GenericCollectionWrapper() { this.results = new ArrayList<>(); } @@ -55,38 +47,18 @@ public class GenericCollectionWrapper<T> implements Serializable { } } - /** - * Gets results. - * - * @return the results - */ public List<T> getResults() { return results; } - /** - * Sets results. - * - * @param results the results - */ public void setResults(List<T> results) { this.results = results; } - /** - * Gets list count. - * - * @return the list count - */ public int getListCount() { return listCount; } - /** - * Sets list count. - * - * @param listCount the list count - */ public void setListCount(int listCount) { this.listCount = listCount; } @@ -94,11 +66,11 @@ public class GenericCollectionWrapper<T> implements Serializable { /** * Add boolean. * - * @param e0 the e 0 + * @param item the list item * @return the boolean */ - public boolean add(T e0) { - if (this.getResults().add(e0)) { + public boolean add(T item) { + if (this.getResults().add(item)) { this.setListCount(this.getResults().size()); return true; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml index 1821dff5dd..907e68f807 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml @@ -2,6 +2,10 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <name>openecomp-sdc-rest-webapp</name> + <packaging>pom</packaging> + <parent> <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-api</artifactId> @@ -9,12 +13,6 @@ <relativePath>../</relativePath> </parent> - <artifactId>openecomp-sdc-rest-webapp</artifactId> - <name>openecomp-sdc-rest-webapp</name> - <packaging>pom</packaging> - - - <modules> <module>/openecomp-sdc-common-rest</module> <module>/vendor-license-rest</module> @@ -24,6 +22,7 @@ <module>/validation-rest</module> <module>/action-library-rest</module> <module>/application-config-rest</module> + <module>/activity-log-rest</module> </modules> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml.versionsBackup new file mode 100644 index 0000000000..cd9b491c08 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/pom.xml.versionsBackup @@ -0,0 +1,28 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <name>openecomp-sdc-rest-webapp</name> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-api</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + <modules> + <module>/openecomp-sdc-common-rest</module> + <module>/vendor-license-rest</module> + <module>/onboarding-rest-war</module> + <module>/vendor-software-products-rest</module> + <module>/sequence-rest</module> + <module>/validation-rest</module> + <module>/action-library-rest</module> + <module>/application-config-rest</module> + </modules> + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/pom.xml.versionsBackup new file mode 100644 index 0000000000..313a50ca9d --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/pom.xml.versionsBackup @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <groupId>org.openecomp.sdc</groupId> + <version>1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>sequence-rest</artifactId> + + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/Service.java b/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/Service.java index 3e1a107b81..134fc479a5 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/Service.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/Service.java @@ -20,5 +20,8 @@ package org.openecomp.sdcrests.service.rest; +/** + * Created by zivl on 6/30/16. + */ public interface Service { } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/services/ServiceImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/services/ServiceImpl.java index 030d4a9c1d..aafe0d4904 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/services/ServiceImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/sequence-rest/src/main/java/org/openecomp/sdcrests/service/rest/services/ServiceImpl.java @@ -22,5 +22,8 @@ package org.openecomp.sdcrests.service.rest.services; import org.openecomp.sdcrests.service.rest.Service; +/** + * Created by zivl on 6/30/16. + */ public class ServiceImpl implements Service { } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/pom.xml index 512a150472..8d1eb94035 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/pom.xml @@ -3,6 +3,10 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>validation-rest</artifactId> + <name>validation-rest</name> + <packaging>pom</packaging> <parent> <groupId>org.openecomp.sdc</groupId> @@ -10,14 +14,8 @@ <version>1.1.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.sdc.onboarding</groupId> - <artifactId>validation-rest</artifactId> - <name>validation-rest</name> - <packaging>pom</packaging> - - <modules> <module>/validation-rest-services</module> <module>/validation-rest-types</module> </modules> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/pom.xml.versionsBackup new file mode 100644 index 0000000000..8bacd99f69 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/pom.xml.versionsBackup @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>validation-rest</artifactId> + <name>validation-rest</name> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + <modules> + <module>/validation-rest-services</module> + <module>/validation-rest-types</module> + </modules> +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml index ba61a0cd0a..6c217ca718 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml @@ -4,15 +4,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <artifactId>validation-rest-services</artifactId> <parent> <groupId>org.openecomp.sdc.onboarding</groupId> <artifactId>validation-rest</artifactId> <version>1.1.0-SNAPSHOT</version> </parent> - <artifactId>validation-rest-services</artifactId> - - <dependencies> <dependency> <groupId>org.springframework</groupId> @@ -46,26 +44,19 @@ <artifactId>cxf-rt-frontend-jaxrs</artifactId> <version>${cxf.version}</version> </dependency> - <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>${http.client.version}</version> </dependency> - <dependency> - <groupId>javax.ws.rs</groupId> - <artifactId>javax.ws.rs-api</artifactId> - <version>${ws.rs.version}</version> - </dependency> - <!-- Other Stuff--> - <dependency> + <!--dependency> <groupId>cglib</groupId> <artifactId>cglib-nodep</artifactId> <version>${cglib.nodep.version}</version> <scope>runtime</scope> - </dependency> + </dependency--> <!-- Java Stuff --> <dependency> @@ -82,7 +73,7 @@ <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-core</artifactId> - <version>1.19.1</version> + <version>${jersey.core.version}</version> <exclusions> <exclusion> <groupId>javax.ws.rs</groupId> @@ -93,7 +84,7 @@ <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-annotations</artifactId> - <version>1.5.3</version> + <version>${swagger.version}</version> </dependency> <dependency> <groupId>org.openecomp.sdc.onboarding</groupId> @@ -103,24 +94,29 @@ <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> - <version>2.7.4</version> + <version>${jackson.annotations.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-xml</artifactId> - <version>2.7.4</version> + <version>${jackson.dataformat.version}</version> </dependency> <dependency> <groupId>org.codehaus.woodstox</groupId> <artifactId>woodstox-core-asl</artifactId> - <version>4.4.1</version> + <version>${woodstox.version}</version> </dependency> - <dependency> <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>com.sun.jersey.contribs</groupId> + <artifactId>jersey-multipart</artifactId> + <version>${jersey.multipart.version}</version> + <scope>provided</scope> + </dependency> </dependencies> @@ -138,7 +134,12 @@ <skipTests>true</skipTests> </configuration> </plugin> + <!-- Error codes generator plugin --> + <!--plugin> + <groupId>org.openecomp.nfv.tools</groupId> + <artifactId>error-codes-maven-plugin</artifactId> + </plugin--> </plugins> </build> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml.versionsBackup new file mode 100644 index 0000000000..ffc417313a --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/pom.xml.versionsBackup @@ -0,0 +1,152 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>validation-rest-services</artifactId> + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>validation-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <dependencies> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context-support</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>${spring.framework.version}</version> + </dependency> + + <!-- CXF --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>${http.client.version}</version> + </dependency> + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + + <!-- Other Stuff--> + <!--dependency> + <groupId>cglib</groupId> + <artifactId>cglib-nodep</artifactId> + <version>${cglib.nodep.version}</version> + <scope>runtime</scope> + </dependency--> + + <!-- Java Stuff --> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>${javax.inject.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-core</artifactId> + <version>1.19.1</version> + <exclusions> + <exclusion> + <groupId>javax.ws.rs</groupId> + <artifactId>jsr311-api</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>1.5.3</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>validation-rest-types</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>2.7.4</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-xml</artifactId> + <version>2.7.4</version> + </dependency> + <dependency> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>woodstox-core-asl</artifactId> + <version>4.4.1</version> + </dependency> + + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.sun.jersey.contribs</groupId> + <artifactId>jersey-multipart</artifactId> + <version>1.18.1</version> + <scope>provided</scope> + </dependency> + + + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>test/core/unittest/offline/**</include> + </includes> + <skipTests>true</skipTests> + </configuration> + </plugin> + <!-- Error codes generator plugin --> + <!--plugin> + <groupId>org.openecomp.nfv.tools</groupId> + <artifactId>error-codes-maven-plugin</artifactId> + </plugin--> + </plugins> + </build> + +</project>
\ No newline at end of file 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 5a1955c0dd..c0c759e123 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 @@ -46,7 +46,6 @@ public interface Validation { @POST @Path("{type}/validate") @Consumes(MediaType.MULTIPART_FORM_DATA) - @ApiOperation(value = "Validate a package") 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 new file mode 100644 index 0000000000..0a737f32e8 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-services/src/main/java/org/openecomp/sdcrests/validation/rest/ValidationForSwaggerUsage.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.validation.rest; + +import com.sun.jersey.multipart.FormDataParam; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +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; + + +@Path("/v1.0/validation") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Validation") +@Validated +public interface ValidationForSwaggerUsage { + + + @POST + @Path("{type}/validate") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @ApiOperation(value = "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 bd8639b682..a5e5205ba0 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 @@ -25,10 +25,16 @@ import org.openecomp.sdc.validation.types.ValidationFileResponse; import org.openecomp.sdcrests.mapping.MappingBase; 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.setErrors(source.getErrors()); + //target.setFileNames(source.getFileNames()); + //target.setStatus(source.getStatus()); 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 88a173de84..b0467b6ef0 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 @@ -20,11 +20,22 @@ package org.openecomp.sdcrests.validation.rest.services; + +import org.openecomp.sdc.common.utils.CommonUtil; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerErrorCode; +import org.openecomp.sdc.logging.types.LoggerErrorDescription; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.validation.UploadValidationManager; import org.openecomp.sdc.validation.types.ValidationFileResponse; import org.openecomp.sdcrests.validation.rest.Validation; import org.openecomp.sdcrests.validation.rest.mapping.MapValidationFileResponseToValidationFileResponseDto; import org.openecomp.sdcrests.validation.types.ValidationFileResponseDto; +import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; @@ -34,28 +45,38 @@ import java.io.InputStream; import javax.inject.Named; import javax.ws.rs.core.Response; - @Named @Service("validation") @Scope(value = "prototype") public class ValidationImpl implements Validation { + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); @Autowired private UploadValidationManager uploadValidationManager; @Override public Response validateFile(String type, InputStream fileToValidate) { + + mdcDataDebugMessage.debugEntryMessage(null, null); + + MDC.put(LoggerConstants.SERVICE_NAME, + LoggerServiceName.Validate.toString()); ValidationFileResponse validationFileResponse = null; try { validationFileResponse = uploadValidationManager.validateFile(type, fileToValidate); - } catch (IOException e0) { - throw new RuntimeException(e0); + } catch (IOException exception) { + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API, + LoggerTragetServiceName.VALIDATE_FILE, ErrorLevel.ERROR.name(), + LoggerErrorCode.DATA_ERROR.getErrorCode(), LoggerErrorDescription.VALIDATE_FILE); + throw new RuntimeException(exception); } ValidationFileResponseDto validationFileResponseDto = new MapValidationFileResponseToValidationFileResponseDto() .applyMapping(validationFileResponse, ValidationFileResponseDto.class); + mdcDataDebugMessage.debugExitMessage(null, null); + return Response.ok(validationFileResponseDto).build(); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml index b4f34969d3..61a4ed3544 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml @@ -4,6 +4,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <artifactId>validation-rest-types</artifactId> + <name>validation-rest-types</name> + <parent> <groupId>org.openecomp.sdc.onboarding</groupId> <artifactId>validation-rest</artifactId> @@ -11,11 +14,6 @@ <relativePath>../</relativePath> </parent> - <artifactId>validation-rest-types</artifactId> - <name>validation-rest-types</name> - - - <dependencies> <dependency> <groupId>org.openecomp.sdc</groupId> @@ -29,4 +27,4 @@ </dependency> </dependencies> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml.versionsBackup new file mode 100644 index 0000000000..5cc8ee7c51 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/validation-rest/validation-rest-types/pom.xml.versionsBackup @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>validation-rest-types</artifactId> + <name>validation-rest-types</name> + + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>validation-rest</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-validation-manager</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> + +</project>
\ No newline at end of file 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 75e59973e3..1ec6568a73 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 @@ -22,8 +22,13 @@ package org.openecomp.sdcrests.validation.types; 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; public ValidationStructureList getValidationData() { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml index 9bb94c5fab..377ffdfa38 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml @@ -2,6 +2,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-license-rest</artifactId> + <name>vendor-license-rest</name> + <packaging>pom</packaging> + <parent> <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-rest-webapp</artifactId> @@ -9,16 +14,9 @@ <relativePath>../</relativePath> </parent> - <groupId>org.openecomp.sdc.onboarding</groupId> - <artifactId>vendor-license-rest</artifactId> - <name>vendor-license-rest</name> - <packaging>pom</packaging> - - - <modules> <module>/vendor-license-rest-services</module> <module>/vendor-license-rest-types</module> </modules> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml.versionsBackup new file mode 100644 index 0000000000..ae9c3063bc --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/pom.xml.versionsBackup @@ -0,0 +1,23 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-license-rest</artifactId> + <name>vendor-license-rest</name> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + <modules> + <module>/vendor-license-rest-services</module> + <module>/vendor-license-rest-types</module> + </modules> + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml index 2002129cd6..513c9f5c7d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml @@ -2,6 +2,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <artifactId>vendor-license-rest-services</artifactId> + <name>vendor-license-rest-services</name> + <parent> <groupId>org.openecomp.sdc.onboarding</groupId> <artifactId>vendor-license-rest</artifactId> @@ -9,11 +12,6 @@ <relativePath>../</relativePath> </parent> - <artifactId>vendor-license-rest-services</artifactId> - <name>vendor-license-rest-services</name> - - - <properties> <errorcode.dir>${project.build.directory}/generated-sources/error-codes</errorcode.dir> @@ -70,7 +68,6 @@ <artifactId>cxf-rt-frontend-jaxrs</artifactId> <version>${cxf.version}</version> </dependency> - <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> @@ -89,12 +86,12 @@ </dependency> <!-- Other Stuff--> - <dependency> + <!--dependency> <groupId>cglib</groupId> <artifactId>cglib-nodep</artifactId> <version>${cglib.nodep.version}</version> <scope>runtime</scope> - </dependency> + </dependency--> <!-- Java Stuff --> <dependency> @@ -124,10 +121,15 @@ <skipTests>true</skipTests> </configuration> </plugin> + <!-- Error codes generator plugin --> + <!--plugin> + <groupId>org.openecomp.nfv.tools</groupId> + <artifactId>error-codes-maven-plugin</artifactId> + </plugin--> </plugins> </build> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml.versionsBackup new file mode 100644 index 0000000000..187135e1f4 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-services/pom.xml.versionsBackup @@ -0,0 +1,135 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>vendor-license-rest-services</artifactId> + <name>vendor-license-rest-services</name> + + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-license-rest</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + + <properties> + <errorcode.dir>${project.build.directory}/generated-sources/error-codes</errorcode.dir> + </properties> + + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vendor-license-rest-types</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-license-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-license-manager</artifactId> + <version>${project.version}</version> + </dependency> + + + <!-- Spring --> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context-support</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>${spring.framework.version}</version> + </dependency> + + <!-- CXF --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>${http.client.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpcore</artifactId> + <version>${http.client.version}</version> + </dependency> + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + + <!-- Other Stuff--> + <!--dependency> + <groupId>cglib</groupId> + <artifactId>cglib-nodep</artifactId> + <version>${cglib.nodep.version}</version> + <scope>runtime</scope> + </dependency--> + + <!-- Java Stuff --> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>${javax.inject.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>test/core/unittest/offline/**</include> + </includes> + <skipTests>true</skipTests> + </configuration> + </plugin> + <!-- Error codes generator plugin --> + <!--plugin> + <groupId>org.openecomp.nfv.tools</groupId> + <artifactId>error-codes-maven-plugin</artifactId> + </plugin--> + </plugins> + </build> + + + + +</project>
\ No newline at end of file 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 9dea767f7d..1f88e4c475 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 @@ -20,20 +20,15 @@ package org.openecomp.sdcrests.vendorlicense.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdcrests.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.validation.constraints.Pattern; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -43,11 +38,13 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@Path("/v1.0/vendor-license-models/{vlmId}/entitlement-pools") +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") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Api(value = "Vendor License Model - Entitlement Pools") @@ -60,9 +57,9 @@ public interface EntitlementPools { responseContainer = "List") Response listEntitlementPools( @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, + + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/") @@ -70,8 +67,11 @@ public interface EntitlementPools { Response createEntitlementPool(@Valid EntitlementPoolRequestDto request, @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam + ("versionId") + String versionId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @Path("/{entitlementPoolId}") @@ -79,9 +79,11 @@ public interface EntitlementPools { Response updateEntitlementPool(@Valid EntitlementPoolRequestDto request, @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") + @PathParam("versionId") String versionId, @NotNull(message = USER_MISSING_ERROR_MSG) @PathParam("entitlementPoolId") String entitlementPoolId, - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @Path("/{entitlementPoolId}") @@ -89,17 +91,17 @@ public interface EntitlementPools { response = EntitlementPoolEntityDto.class) Response getEntitlementPool( @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, @PathParam("entitlementPoolId") String entitlementPoolId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{entitlementPoolId}") @ApiOperation(value = "Delete vendor entitlement pool") Response deleteEntitlementPool( @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, @PathParam("entitlementPoolId") String entitlementPoolId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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 f5ad973cb0..9a72a59070 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 @@ -20,9 +20,6 @@ package org.openecomp.sdcrests.vendorlicense.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -49,7 +46,11 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@Path("/v1.0/vendor-license-models/{vlmId}/feature-groups") +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) @Api(value = "Vendor License Model - Feature Groups") @@ -63,9 +64,8 @@ public interface FeatureGroups { responseContainer = "List") Response listFeatureGroups( @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/") @@ -73,8 +73,9 @@ public interface FeatureGroups { Response createFeatureGroup(@Valid FeatureGroupRequestDto request, @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @Path("/{featureGroupId}") @@ -82,9 +83,10 @@ public interface FeatureGroups { Response updateFeatureGroup(@Valid FeatureGroupUpdateRequestDto request, @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, @PathParam("featureGroupId") String featureGroupId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @Path("/{featureGroupId}") @@ -92,17 +94,17 @@ public interface FeatureGroups { response = FeatureGroupModelDto.class) Response getFeatureGroup( @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, @PathParam("featureGroupId") String featureGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{featureGroupId}") @ApiOperation(value = "Delete vendor feature group") Response deleteFeatureGroup( @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, @PathParam("featureGroupId") String featureGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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 28d9f5a32f..4eabec91a6 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 @@ -20,13 +20,9 @@ package org.openecomp.sdcrests.vendorlicense.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementEntityDto; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementModelDto; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementRequestDto; @@ -35,7 +31,6 @@ import org.springframework.validation.annotation.Validated; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -45,11 +40,14 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@Path("/v1.0/vendor-license-models/{vlmId}/license-agreements") +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) @Api(value = "Vendor License Model - License Agreements") @@ -64,9 +62,8 @@ public interface LicenseAgreements { responseContainer = "List") Response listLicenseAgreements( @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/") @@ -74,8 +71,10 @@ public interface LicenseAgreements { Response createLicenseAgreement(@Valid LicenseAgreementRequestDto request, @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") + @PathParam("versionId") String versionId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @Path("/{licenseAgreementId}") @@ -83,9 +82,11 @@ public interface LicenseAgreements { Response updateLicenseAgreement(@Valid LicenseAgreementUpdateRequestDto request, @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") + @PathParam("versionId") String versionId, @PathParam("licenseAgreementId") String licenseAgreementId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @Path("/{licenseAgreementId}") @@ -93,17 +94,17 @@ public interface LicenseAgreements { response = LicenseAgreementModelDto.class) Response getLicenseAgreement( @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, @PathParam("licenseAgreementId") String licenseAgreementId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{licenseAgreementId}") @ApiOperation(value = "Delete vendor license agreement") Response deleteLicenseAgreement( @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, @PathParam("licenseAgreementId") String licenseAgreementId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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 d66945d63c..973e3c22d4 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 @@ -20,20 +20,15 @@ package org.openecomp.sdcrests.vendorlicense.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdcrests.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.validation.constraints.Pattern; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -43,11 +38,14 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@Path("/v1.0/vendor-license-models/{vlmId}/license-key-groups") +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") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Api(value = "Vendor License Model - License Key Groups") @@ -60,9 +58,8 @@ public interface LicenseKeyGroups { responseContainer = "List") Response listLicenseKeyGroups( @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, - @HeaderParam(USER_HEADER_PARAM) String user); + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, + @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/") @@ -70,8 +67,10 @@ public interface LicenseKeyGroups { Response createLicenseKeyGroup(@Valid LicenseKeyGroupRequestDto request, @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") + @PathParam("versionId") String versionId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @Path("/{licenseKeyGroupId}") @@ -79,9 +78,11 @@ public interface LicenseKeyGroups { Response updateLicenseKeyGroup(@Valid LicenseKeyGroupRequestDto request, @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") + @PathParam("versionId") String versionId, @PathParam("licenseKeyGroupId") String licenseKeyGroupId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @Path("/{licenseKeyGroupId}") @@ -89,16 +90,16 @@ public interface LicenseKeyGroups { response = LicenseKeyGroupEntityDto.class) Response getLicenseKeyGroup( @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, @PathParam("licenseKeyGroupId") String licenseKeyGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{licenseKeyGroupId}") @ApiOperation(value = "Delete vendor license key group") Response deleteLicenseKeyGroup( @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "Vendor license model version Id") @PathParam("versionId") String versionId, @PathParam("licenseKeyGroupId") String licenseKeyGroupId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } 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 15fc9bf0d9..23a0960a3a 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 @@ -20,12 +20,9 @@ package org.openecomp.sdcrests.vendorlicense.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdcrests.common.RestConstants; import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelActionRequestDto; import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto; @@ -34,20 +31,13 @@ import org.springframework.validation.annotation.Validated; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + + @Path("/v1.0/vendor-license-models") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @@ -55,57 +45,65 @@ import javax.ws.rs.core.Response; @Validated public interface VendorLicenseModels { - @GET - @Path("/") - @ApiOperation(value = "List vendor license models", - response = VendorLicenseModelEntityDto.class, - responseContainer = "List") - Response listLicenseModels(@ApiParam( - value = "Currently supported value: 'Final' - only vendor License models with final versions " - + "will be return - with their latest final version") - @QueryParam("versionFilter") String versionFilter, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_HEADER_PARAM) String user); + @GET + @Path("/") + @ApiOperation(value = "List vendor license models", + response = VendorLicenseModelEntityDto.class, + responseContainer = "List") + Response listLicenseModels(@ApiParam( + value = "Currently supported value: 'Final' - only vendor License models with final versions " + + "will be return - with their latest final version") + @QueryParam("versionFilter") String versionFilter, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(RestConstants.USER_ID_HEADER_PARAM) String user); - @POST - @Path("/") - @ApiOperation(value = "Create vendor license model") - Response createLicenseModel(@Valid VendorLicenseModelRequestDto request, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_HEADER_PARAM) String user); + @POST + @Path("/") + @ApiOperation(value = "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}") - @ApiOperation(value = "Update vendor license model") - Response updateLicenseModel(@Valid VendorLicenseModelRequestDto request, - @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") - String vlmId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_HEADER_PARAM) String user); + @PUT + @Path("/{vlmId}/versions/{versionId}") + @ApiOperation(value = "Update vendor license model") + Response updateLicenseModel(@Valid VendorLicenseModelRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, + @ApiParam(value = "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}") - @ApiOperation(value = "Get vendor license model", - response = VendorLicenseModelEntityDto.class) - Response getLicenseModel( - @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_HEADER_PARAM) - String user); + @GET + @Path("/{vlmId}/versions/{versionId}") + @ApiOperation(value = "Get vendor license model", + response = VendorLicenseModelEntityDto.class) + Response getLicenseModel( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "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}") - @ApiOperation(value = "Delete vendor license model") - Response deleteLicenseModel( - @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(RestConstants.USER_HEADER_PARAM) - String user); + @DELETE + @Path("/{vlmId}/versions/{versionId}") + @ApiOperation(value = "Delete vendor license model") + Response deleteLicenseModel( + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") String vlmId, + @ApiParam(value = "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}/actions") - @ApiOperation(value = "Update vendor license model") - Response actOnLicenseModel(@Valid VendorLicenseModelActionRequestDto request, - @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") - String vlmId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(RestConstants.USER_HEADER_PARAM) String user); + @PUT + @Path("/{vlmId}/versions/{versionId}/actions") + @ApiOperation(value = "Update vendor license model") + Response actOnLicenseModel(@Valid VendorLicenseModelActionRequestDto request, + @ApiParam(value = "Vendor license model Id") @PathParam("vlmId") + String vlmId, + @ApiParam(value = "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/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 91239e2655..9875a332bd 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 @@ -24,7 +24,6 @@ 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 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 1117a2db9f..593a4a37b0 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 @@ -24,7 +24,6 @@ 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 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/MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto.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/MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto.java index a53d5c9e36..7c2db85d2e 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/MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto.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/MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto.java @@ -25,6 +25,7 @@ import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.types.VersionInfo; +import org.openecomp.sdcrests.common.types.VersionDto; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto; @@ -42,17 +43,20 @@ public class MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto VersionInfo versionInfo = source.getVersionInfo(); if (versionInfo != null) { - target.setVersion(versionInfo.getActiveVersion().toString()); + target.setVersion(new VersionDto(versionInfo.getActiveVersion().toString(),versionInfo + .getActiveVersion().toString())); target.setStatus(versionInfo.getStatus()); target.setLockingUser(versionInfo.getLockingUser()); if (!CommonMethods.isEmpty(versionInfo.getViewableVersions())) { - target.setViewableVersions(versionInfo.getViewableVersions().stream().map(Version::toString) + target.setViewableVersions(versionInfo.getViewableVersions().stream().map(version->new + VersionDto(version.toString(),version.toString())) .collect(Collectors.toList())); } if (!CommonMethods.isEmpty(versionInfo.getFinalVersions())) { - target.setFinalVersions(versionInfo.getFinalVersions().stream().map(Version::toString) + target.setFinalVersions(versionInfo.getFinalVersions().stream().map(version->new + VersionDto(version.toString(),version.toString())) .collect(Collectors.toList())); } } 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 ab9800e612..63576c95bd 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 @@ -20,10 +20,12 @@ package org.openecomp.sdcrests.vendorlicense.rest.services; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; import org.openecomp.sdc.versioning.dao.types.Version; - import org.openecomp.sdcrests.vendorlicense.rest.EntitlementPools; import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapEntitlementPoolEntityToEntitlementPoolEntityDto; import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapEntitlementPoolRequestDtoToEntitlementPoolEntity; @@ -31,34 +33,37 @@ import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolEntityDto; import org.openecomp.sdcrests.vendorlicense.types.EntitlementPoolRequestDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import java.util.Collection; import javax.inject.Named; import javax.ws.rs.core.Response; +import java.util.Collection; @Named @Service("entitlementPools") @Scope(value = "prototype") public class EntitlementPoolsImpl implements EntitlementPools { + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); @Autowired private VendorLicenseManager vendorLicenseManager; /** * List entitlement pools response. * - * @param vlmId the vlm id - * @param version the version - * @param user the user + * @param vlmId the vlm id + * @param versionId the version + * @param user the user * @return the response */ - public Response listEntitlementPools(String vlmId, String version, String user) { + public Response listEntitlementPools(String vlmId, String versionId, String user) { + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); + + MdcUtil.initMdc(LoggerServiceName.List_EP.toString()); Collection<EntitlementPoolEntity> entitlementPools = - vendorLicenseManager.listEntitlementPools(vlmId, Version.valueOf(version), user); + vendorLicenseManager.listEntitlementPools(vlmId, Version.valueOf(versionId), user); GenericCollectionWrapper<EntitlementPoolEntityDto> result = new GenericCollectionWrapper<>(); MapEntitlementPoolEntityToEntitlementPoolEntityDto outputMapper = @@ -67,6 +72,8 @@ public class EntitlementPoolsImpl implements EntitlementPools { result.add(outputMapper.applyMapping(ep, EntitlementPoolEntityDto.class)); } + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); + return Response.ok(result).build(); } @@ -79,7 +86,11 @@ public class EntitlementPoolsImpl implements EntitlementPools { * @return the response */ public Response createEntitlementPool(EntitlementPoolRequestDto request, String vlmId, - String user) { + String versionId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); + + MdcUtil.initMdc(LoggerServiceName.Create_EP.toString()); EntitlementPoolEntity entitlementPoolEntity = new MapEntitlementPoolRequestDtoToEntitlementPoolEntity() .applyMapping(request, EntitlementPoolEntity.class); @@ -91,6 +102,8 @@ public class EntitlementPoolsImpl implements EntitlementPools { createdEntitlementPool != null ? new StringWrapperResponse(createdEntitlementPool.getId()) : null; + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); + return Response.ok(result).build(); } @@ -104,15 +117,21 @@ public class EntitlementPoolsImpl implements EntitlementPools { * @return the response */ public Response updateEntitlementPool(EntitlementPoolRequestDto request, String vlmId, - String entitlementPoolId, String user) { + String versionId, String entitlementPoolId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", vlmId, entitlementPoolId); + + MdcUtil.initMdc(LoggerServiceName.Update_EP.toString()); EntitlementPoolEntity entitlementPoolEntity = new MapEntitlementPoolRequestDtoToEntitlementPoolEntity() .applyMapping(request, EntitlementPoolEntity.class); - entitlementPoolEntity.setVendorLicenseModelId(vlmId); entitlementPoolEntity.setId(entitlementPoolId); vendorLicenseManager.updateEntitlementPool(entitlementPoolEntity, user); + + mdcDataDebugMessage.debugExitMessage("VLM id, EP id", vlmId, entitlementPoolId); + return Response.ok().build(); } @@ -127,6 +146,10 @@ public class EntitlementPoolsImpl implements EntitlementPools { */ public Response getEntitlementPool(String vlmId, String version, String entitlementPoolId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", vlmId, entitlementPoolId); + + MdcUtil.initMdc(LoggerServiceName.Get_EP.toString()); EntitlementPoolEntity epInput = new EntitlementPoolEntity(); epInput.setVendorLicenseModelId(vlmId); epInput.setVersion(Version.valueOf(version)); @@ -136,6 +159,9 @@ public class EntitlementPoolsImpl implements EntitlementPools { EntitlementPoolEntityDto entitlementPoolEntityDto = entitlementPool == null ? null : new MapEntitlementPoolEntityToEntitlementPoolEntityDto() .applyMapping(entitlementPool, EntitlementPoolEntityDto.class); + + mdcDataDebugMessage.debugExitMessage("VLM id, EP id", vlmId, entitlementPoolId); + return Response.ok(entitlementPoolEntityDto).build(); } @@ -147,11 +173,19 @@ public class EntitlementPoolsImpl implements EntitlementPools { * @param user the user * @return the response */ - public Response deleteEntitlementPool(String vlmId, String entitlementPoolId, String user) { + public Response deleteEntitlementPool(String vlmId, String versionId, String entitlementPoolId, + String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id, EP id", vlmId, entitlementPoolId); + + MdcUtil.initMdc(LoggerServiceName.Delete_EP.toString()); EntitlementPoolEntity epInput = new EntitlementPoolEntity(); epInput.setVendorLicenseModelId(vlmId); epInput.setId(entitlementPoolId); vendorLicenseManager.deleteEntitlementPool(epInput, user); + + mdcDataDebugMessage.debugExitMessage("VLM id, EP id", vlmId, entitlementPoolId); + 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 daf35f9ee6..e41942d455 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 @@ -21,6 +21,9 @@ package org.openecomp.sdcrests.vendorlicense.rest.services; import org.openecomp.core.utilities.CommonMethods; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; @@ -40,29 +43,32 @@ import org.openecomp.sdcrests.vendorlicense.types.FeatureGroupUpdateRequestDto; import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import java.util.Collection; -import java.util.HashSet; import javax.inject.Named; import javax.ws.rs.core.Response; - +import java.util.Collection; +import java.util.HashSet; @Named @Service("featureGroups") @Scope(value = "prototype") public class FeatureGroupsImpl implements FeatureGroups { + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); @Autowired private VendorLicenseManager vendorLicenseManager; @Override - public Response listFeatureGroups(String vlmId, String version, String user) { + public Response listFeatureGroups(String vlmId, String versionId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); + + MdcUtil.initMdc(LoggerServiceName.List_FG.toString()); Collection<FeatureGroupEntity> featureGroupEntities = - vendorLicenseManager.listFeatureGroups(vlmId, Version.valueOf(version), user); + vendorLicenseManager.listFeatureGroups(vlmId, Version.valueOf(versionId), user); MapFeatureGroupEntityToFeatureGroupDescriptorDto outputMapper = new MapFeatureGroupEntityToFeatureGroupDescriptorDto(); @@ -78,11 +84,18 @@ public class FeatureGroupsImpl implements FeatureGroups { results.add(fgDto); } + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); + return Response.ok(results).build(); } @Override - public Response createFeatureGroup(FeatureGroupRequestDto request, String vlmId, String user) { + public Response createFeatureGroup(FeatureGroupRequestDto request, String vlmId, String versionId, + String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); + + MdcUtil.initMdc(LoggerServiceName.Create_FG.toString()); FeatureGroupEntity featureGroupEntity = new MapFeatureGroupDescriptorDtoToFeatureGroupEntity() .applyMapping(request, FeatureGroupEntity.class); featureGroupEntity.setVendorLicenseModelId(vlmId); @@ -94,12 +107,19 @@ public class FeatureGroupsImpl implements FeatureGroups { StringWrapperResponse result = createdFeatureGroup != null ? new StringWrapperResponse(createdFeatureGroup.getId()) : null; + + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); + return Response.ok(result).build(); } @Override public Response updateFeatureGroup(FeatureGroupUpdateRequestDto request, String vlmId, - String featureGroupId, String user) { + String versionId, String featureGroupId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id, FG id", vlmId, featureGroupId); + + MdcUtil.initMdc(LoggerServiceName.Update_FG.toString()); FeatureGroupEntity featureGroupEntity = new MapFeatureGroupDescriptorDtoToFeatureGroupEntity() .applyMapping(request, FeatureGroupEntity.class); featureGroupEntity.setVendorLicenseModelId(vlmId); @@ -109,15 +129,22 @@ public class FeatureGroupsImpl implements FeatureGroups { .updateFeatureGroup(featureGroupEntity, request.getAddedLicenseKeyGroupsIds(), request.getRemovedLicenseKeyGroupsIds(), request.getAddedEntitlementPoolsIds(), request.getRemovedEntitlementPoolsIds(), user); + + mdcDataDebugMessage.debugExitMessage("VLM id, FG id", vlmId, featureGroupId); + return Response.ok().build(); } @Override - public Response getFeatureGroup(String vlmId, String version, String featureGroupId, + public Response getFeatureGroup(String vlmId, String versionId, String featureGroupId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id, FG id", vlmId, featureGroupId); + + MdcUtil.initMdc(LoggerServiceName.Get_FG.toString()); FeatureGroupEntity fgInput = new FeatureGroupEntity(); fgInput.setVendorLicenseModelId(vlmId); - fgInput.setVersion(Version.valueOf(version)); + fgInput.setVersion(Version.valueOf(versionId)); fgInput.setId(featureGroupId); FeatureGroupModel featureGroupModel = vendorLicenseManager.getFeatureGroupModel(fgInput, user); @@ -154,15 +181,25 @@ public class FeatureGroupsImpl implements FeatureGroups { } } + mdcDataDebugMessage.debugExitMessage("VLM id, FG id", vlmId, featureGroupId); + return Response.ok(fgmDto).build(); } @Override - public Response deleteFeatureGroup(String vlmId, String featureGroupId, String user) { + public Response deleteFeatureGroup(String vlmId, String versionId, String featureGroupId, + String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id, FG id", vlmId, featureGroupId); + + MdcUtil.initMdc(LoggerServiceName.Delete_FG.toString()); FeatureGroupEntity fgInput = new FeatureGroupEntity(); fgInput.setVendorLicenseModelId(vlmId); fgInput.setId(featureGroupId); vendorLicenseManager.deleteFeatureGroup(fgInput, user); + + mdcDataDebugMessage.debugExitMessage("VLM id, FG id", vlmId, featureGroupId); + 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/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 d87be05998..ac242422e4 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 @@ -21,6 +21,9 @@ package org.openecomp.sdcrests.vendorlicense.rest.services; import org.openecomp.core.utilities.CommonMethods; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity; import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity; @@ -37,7 +40,6 @@ import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementRequestDto; import org.openecomp.sdcrests.vendorlicense.types.LicenseAgreementUpdateRequestDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; @@ -52,6 +54,7 @@ import javax.ws.rs.core.Response; @Scope(value = "prototype") public class LicenseAgreementsImpl implements LicenseAgreements { + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); @Autowired private VendorLicenseManager vendorLicenseManager; @@ -59,13 +62,17 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * List license agreements response. * * @param vlmId the vlm id - * @param version the version + * @param versionId the version * @param user the user * @return the response */ - public Response listLicenseAgreements(String vlmId, String version, String user) { + public Response listLicenseAgreements(String vlmId, String versionId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); + + MdcUtil.initMdc(LoggerServiceName.List_LA.toString()); Collection<LicenseAgreementEntity> licenseAgreements = - vendorLicenseManager.listLicenseAgreements(vlmId, Version.valueOf(version), user); + vendorLicenseManager.listLicenseAgreements(vlmId, Version.valueOf(versionId), user); GenericCollectionWrapper<LicenseAgreementEntityDto> results = new GenericCollectionWrapper<>(); MapLicenseAgreementEntityToLicenseAgreementDescriptorDto outputMapper = @@ -78,6 +85,8 @@ public class LicenseAgreementsImpl implements LicenseAgreements { results.add(laeDto); } + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); + return Response.ok(results).build(); } @@ -90,11 +99,16 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * @return the response */ public Response createLicenseAgreement(LicenseAgreementRequestDto request, String vlmId, - String user) { + String versionId,String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); + + MdcUtil.initMdc(LoggerServiceName.Create_LA.toString()); LicenseAgreementEntity licenseAgreementEntity = new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity() .applyMapping(request, LicenseAgreementEntity.class); licenseAgreementEntity.setVendorLicenseModelId(vlmId); + licenseAgreementEntity.setVersion(Version.valueOf(versionId)); licenseAgreementEntity.setFeatureGroupIds(request.getAddedFeatureGroupsIds()); LicenseAgreementEntity createdLicenseAgreement = @@ -103,6 +117,8 @@ public class LicenseAgreementsImpl implements LicenseAgreements { createdLicenseAgreement != null ? new StringWrapperResponse(createdLicenseAgreement.getId()) : null; + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); + return Response.ok(result).build(); } @@ -116,16 +132,24 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * @return the response */ public Response updateLicenseAgreement(LicenseAgreementUpdateRequestDto request, String vlmId, - String licenseAgreementId, String user) { + String versionId,String licenseAgreementId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId); + + MdcUtil.initMdc(LoggerServiceName.Update_LA.toString()); LicenseAgreementEntity licenseAgreementEntity = new MapLicenseAgreementDescriptorDtoToLicenseAgreementEntity() .applyMapping(request, LicenseAgreementEntity.class); licenseAgreementEntity.setVendorLicenseModelId(vlmId); + licenseAgreementEntity.setVersion(Version.valueOf(versionId)); licenseAgreementEntity.setId(licenseAgreementId); vendorLicenseManager .updateLicenseAgreement(licenseAgreementEntity, request.getAddedFeatureGroupsIds(), request.getRemovedFeatureGroupsIds(), user); + + mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId); + return Response.ok().build(); } @@ -133,15 +157,19 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * Gets license agreement. * * @param vlmId the vlm id - * @param version the version + * @param versionId the version * @param licenseAgreementId the license agreement id * @param user the user * @return the license agreement */ - public Response getLicenseAgreement(String vlmId, String version, String licenseAgreementId, + public Response getLicenseAgreement(String vlmId, String versionId, String licenseAgreementId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId); + + MdcUtil.initMdc(LoggerServiceName.Get_LA.toString()); LicenseAgreementModel licenseAgreementModel = vendorLicenseManager - .getLicenseAgreementModel(vlmId, Version.valueOf(version), licenseAgreementId, user); + .getLicenseAgreementModel(vlmId, Version.valueOf(versionId), licenseAgreementId, user); if (licenseAgreementModel == null) { return Response.ok().build(); @@ -168,6 +196,8 @@ public class LicenseAgreementsImpl implements LicenseAgreements { } } + mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId); + return Response.ok(lamDto).build(); } @@ -175,12 +205,21 @@ public class LicenseAgreementsImpl implements LicenseAgreements { * Delete license agreement response. * * @param vlmId the vlm id - * @param licenseAgreementId the license agreement id + * @param versionId the version id + * @param licenseAgreementId the license agreement id * @param user the user * @return the response */ - public Response deleteLicenseAgreement(String vlmId, String licenseAgreementId, String user) { - vendorLicenseManager.deleteLicenseAgreement(vlmId, licenseAgreementId, user); + public Response deleteLicenseAgreement(String vlmId,String versionId, String licenseAgreementId, + String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id, LA id", vlmId, licenseAgreementId); + + MdcUtil.initMdc(LoggerServiceName.Delete_LA.toString()); + vendorLicenseManager.deleteLicenseAgreement(vlmId, Version.valueOf(versionId), licenseAgreementId, user); + + mdcDataDebugMessage.debugExitMessage("VLM id, LA id", vlmId, licenseAgreementId); + 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/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 6ef7e194b8..2aac474123 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 @@ -20,10 +20,12 @@ package org.openecomp.sdcrests.vendorlicense.rest.services; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity; import org.openecomp.sdc.versioning.dao.types.Version; - import org.openecomp.sdcrests.vendorlicense.rest.LicenseKeyGroups; import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto; import org.openecomp.sdcrests.vendorlicense.rest.mapping.MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity; @@ -31,15 +33,14 @@ import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupEntityDto; import org.openecomp.sdcrests.vendorlicense.types.LicenseKeyGroupRequestDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import java.util.Collection; import javax.inject.Named; import javax.ws.rs.core.Response; +import java.util.Collection; @Named @Service("licenseKeyGroups") @@ -47,20 +48,25 @@ import javax.ws.rs.core.Response; @Validated public class LicenseKeyGroupsImpl implements LicenseKeyGroups { + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); @Autowired private VendorLicenseManager vendorLicenseManager; /** * List license key groups response. * - * @param vlmId the vlm id - * @param version the version - * @param user the user + * @param vlmId the vlm id + * @param versionId the version + * @param user the user * @return the response */ - public Response listLicenseKeyGroups(String vlmId, String version, String user) { + public Response listLicenseKeyGroups(String vlmId, String versionId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); + + MdcUtil.initMdc(LoggerServiceName.List_LKG.toString()); Collection<LicenseKeyGroupEntity> licenseKeyGroups = - vendorLicenseManager.listLicenseKeyGroups(vlmId, Version.valueOf(version), user); + vendorLicenseManager.listLicenseKeyGroups(vlmId, Version.valueOf(versionId), user); GenericCollectionWrapper<LicenseKeyGroupEntityDto> result = new GenericCollectionWrapper<>(); MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto outputMapper = @@ -69,6 +75,8 @@ public class LicenseKeyGroupsImpl implements LicenseKeyGroups { result.add(outputMapper.applyMapping(ep, LicenseKeyGroupEntityDto.class)); } + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); + return Response.ok(result).build(); } @@ -81,7 +89,11 @@ public class LicenseKeyGroupsImpl implements LicenseKeyGroups { * @return the response */ public Response createLicenseKeyGroup(LicenseKeyGroupRequestDto request, String vlmId, - String user) { + String versionId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); + + MdcUtil.initMdc(LoggerServiceName.Create_LKG.toString()); LicenseKeyGroupEntity licenseKeyGroupEntity = new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity() .applyMapping(request, LicenseKeyGroupEntity.class); @@ -93,6 +105,8 @@ public class LicenseKeyGroupsImpl implements LicenseKeyGroups { createdLicenseKeyGroup != null ? new StringWrapperResponse(createdLicenseKeyGroup.getId()) : null; + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); + return Response.ok(result).build(); } @@ -106,15 +120,22 @@ public class LicenseKeyGroupsImpl implements LicenseKeyGroups { * @return the response */ public Response updateLicenseKeyGroup(LicenseKeyGroupRequestDto request, String vlmId, + String versionId, String licenseKeyGroupId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", vlmId, licenseKeyGroupId); + + MdcUtil.initMdc(LoggerServiceName.Update_LKG.toString()); LicenseKeyGroupEntity licenseKeyGroupEntity = new MapLicenseKeyGroupRequestDtoToLicenseKeyGroupEntity() .applyMapping(request, LicenseKeyGroupEntity.class); - licenseKeyGroupEntity.setVendorLicenseModelId(vlmId); licenseKeyGroupEntity.setId(licenseKeyGroupId); vendorLicenseManager.updateLicenseKeyGroup(licenseKeyGroupEntity, user); + + mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", vlmId, licenseKeyGroupId); + return Response.ok().build(); } @@ -122,22 +143,29 @@ public class LicenseKeyGroupsImpl implements LicenseKeyGroups { * Gets license key group. * * @param vlmId the vlm id - * @param version the version + * @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 version, String licenseKeyGroupId, + public Response getLicenseKeyGroup(String vlmId, String versionId, String licenseKeyGroupId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", vlmId, licenseKeyGroupId); + + MdcUtil.initMdc(LoggerServiceName.Get_LKG.toString()); LicenseKeyGroupEntity lkgInput = new LicenseKeyGroupEntity(); lkgInput.setVendorLicenseModelId(vlmId); - lkgInput.setVersion(Version.valueOf(version)); + lkgInput.setVersion(Version.valueOf(versionId)); lkgInput.setId(licenseKeyGroupId); LicenseKeyGroupEntity licenseKeyGroup = vendorLicenseManager.getLicenseKeyGroup(lkgInput, user); LicenseKeyGroupEntityDto licenseKeyGroupEntityDto = licenseKeyGroup == null ? null : new MapLicenseKeyGroupEntityToLicenseKeyGroupEntityDto() .applyMapping(licenseKeyGroup, LicenseKeyGroupEntityDto.class); + + mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", vlmId, licenseKeyGroupId); + return Response.ok(licenseKeyGroupEntityDto).build(); } @@ -149,11 +177,19 @@ public class LicenseKeyGroupsImpl implements LicenseKeyGroups { * @param user the user * @return the response */ - public Response deleteLicenseKeyGroup(String vlmId, String licenseKeyGroupId, String user) { + public Response deleteLicenseKeyGroup(String vlmId, String versionId, String licenseKeyGroupId, + String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id, LKG id", vlmId, licenseKeyGroupId); + + MdcUtil.initMdc(LoggerServiceName.Delete_LKG.toString()); LicenseKeyGroupEntity lkgInput = new LicenseKeyGroupEntity(); lkgInput.setVendorLicenseModelId(vlmId); lkgInput.setId(licenseKeyGroupId); vendorLicenseManager.deleteLicenseKeyGroup(lkgInput, user); + + mdcDataDebugMessage.debugExitMessage("VLM id, LKG id", vlmId, licenseKeyGroupId); + 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 c63da86e7a..9e72170e04 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 @@ -20,6 +20,13 @@ package org.openecomp.sdcrests.vendorlicense.rest.services; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.logging.messages.AuditMessages; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdc.vendorlicense.VendorLicenseManager; import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity; import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel; @@ -32,16 +39,15 @@ import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelEntityDto; import org.openecomp.sdcrests.vendorlicense.types.VendorLicenseModelRequestDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; +import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import java.util.Collection; import javax.inject.Named; import javax.ws.rs.core.Response; - - +import java.util.Collection; @Named @Service("vendorLicenseModels") @@ -49,27 +55,42 @@ import javax.ws.rs.core.Response; @Validated public class VendorLicenseModelsImpl implements VendorLicenseModels { + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); @Autowired private VendorLicenseManager vendorLicenseManager; + private static final Logger logger = + LoggerFactory.getLogger(VendorLicenseModelsImpl.class); + + @Override + public Response listLicenseModels(String versionFilter, String user) { + + mdcDataDebugMessage.debugEntryMessage(null, null); + MdcUtil.initMdc(LoggerServiceName.List_VLM.toString()); + Collection<VersionedVendorLicenseModel> versionedVendorLicenseModels = + vendorLicenseManager.listVendorLicenseModels(versionFilter, user); + + GenericCollectionWrapper<VendorLicenseModelEntityDto> results = + new GenericCollectionWrapper<>(); + MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto outputMapper = + new MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto(); + for (VersionedVendorLicenseModel versionedVlm : versionedVendorLicenseModels) { + results.add(outputMapper.applyMapping(versionedVlm, VendorLicenseModelEntityDto.class)); + } + + mdcDataDebugMessage.debugExitMessage(null, null); - @Override - public Response listLicenseModels(String versionFilter, String user) { - Collection<VersionedVendorLicenseModel> versionedVendorLicenseModels = - vendorLicenseManager.listVendorLicenseModels(versionFilter, user); - - GenericCollectionWrapper<VendorLicenseModelEntityDto> results = - new GenericCollectionWrapper<>(); - MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto outputMapper = - new MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto(); - for (VersionedVendorLicenseModel versionedVlm : versionedVendorLicenseModels) { - results.add(outputMapper.applyMapping(versionedVlm, VendorLicenseModelEntityDto.class)); + return Response.ok(results).build(); } - return Response.ok(results).build(); - } + @Override + public Response createLicenseModel(VendorLicenseModelRequestDto request, String user) { - @Override - public Response createLicenseModel(VendorLicenseModelRequestDto request, String user) { + mdcDataDebugMessage.debugEntryMessage(null, null); + + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_VLM + + request.getVendorName()); + + MdcUtil.initMdc(LoggerServiceName.Create_VLM.toString()); VendorLicenseModelEntity vendorLicenseModelEntity = new MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity() .applyMapping(request, VendorLicenseModelEntity.class); @@ -78,58 +99,95 @@ public class VendorLicenseModelsImpl implements VendorLicenseModels { StringWrapperResponse result = createdVendorLicenseModel != null ? new StringWrapperResponse( createdVendorLicenseModel.getId()) : null; - return Response.ok(result).build(); - } + mdcDataDebugMessage.debugExitMessage(null, null); - @Override - public Response updateLicenseModel(VendorLicenseModelRequestDto request, String vlmId, - String user) { - VendorLicenseModelEntity vendorLicenseModelEntity = - new MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity() - .applyMapping(request, VendorLicenseModelEntity.class); - vendorLicenseModelEntity.setId(vlmId); + return Response.ok(result).build(); + } - vendorLicenseManager.updateVendorLicenseModel(vendorLicenseModelEntity, user); - return Response.ok().build(); - } + @Override + public Response updateLicenseModel(VendorLicenseModelRequestDto request, String vlmId, + String versionId, String user) { - @Override - public Response getLicenseModel(String vlmId, String version, String user) { - VersionedVendorLicenseModel versionedVlm = - vendorLicenseManager.getVendorLicenseModel(vlmId, Version.valueOf(version), user); + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); - VendorLicenseModelEntityDto vlmDto = versionedVlm == null ? null : - new MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto() - .applyMapping(versionedVlm, VendorLicenseModelEntityDto.class); - return Response.ok(vlmDto).build(); - } + MdcUtil.initMdc(LoggerServiceName.Update_VLM.toString()); + VendorLicenseModelEntity vendorLicenseModelEntity = + new MapVendorLicenseModelRequestDtoToVendorLicenseModelEntity() + .applyMapping(request, VendorLicenseModelEntity.class); + vendorLicenseModelEntity.setId(vlmId); - @Override - public Response deleteLicenseModel(String vlmId, String user) { - vendorLicenseManager.deleteVendorLicenseModel(vlmId, user); - return Response.ok().build(); - } + vendorLicenseManager.updateVendorLicenseModel(vendorLicenseModelEntity, user); - @Override - public Response actOnLicenseModel(VendorLicenseModelActionRequestDto request, String vlmId, - String user) { + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); + + return Response.ok().build(); + } + + @Override + public Response getLicenseModel(String vlmId, String versionId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); + + MdcUtil.initMdc(LoggerServiceName.Get_VLM.toString()); + VersionedVendorLicenseModel versionedVlm = + vendorLicenseManager.getVendorLicenseModel(vlmId, Version.valueOf(versionId), user); + + VendorLicenseModelEntityDto vlmDto = versionedVlm == null ? null : + new MapVersionedVendorLicenseModelToVendorLicenseModelEntityDto() + .applyMapping(versionedVlm, VendorLicenseModelEntityDto.class); + + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); + + return Response.ok(vlmDto).build(); + } + + @Override + public Response deleteLicenseModel(String vlmId, String versionId, String user) { + + mdcDataDebugMessage.debugEntryMessage("VLM id", vlmId); + + MdcUtil.initMdc(LoggerServiceName.Delete_VLM.toString()); + vendorLicenseManager.deleteVendorLicenseModel(vlmId, user); + + mdcDataDebugMessage.debugExitMessage("VLM id", vlmId); + + return Response.ok().build(); + } + + @Override + public Response actOnLicenseModel(VendorLicenseModelActionRequestDto request, String vlmId, + String versionId, String user) { switch (request.getAction()) { case Checkout: + MDC.put(LoggerConstants.SERVICE_NAME, + LoggerServiceName.Checkout_VLM.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CHECK_OUT_VLM + + vlmId); vendorLicenseManager.checkout(vlmId, user); break; case Undo_Checkout: + MDC.put(LoggerConstants.SERVICE_NAME, + LoggerServiceName.Undo_Checkout_VLM.toString()); vendorLicenseManager.undoCheckout(vlmId, user); break; case Checkin: + MDC.put(LoggerConstants.SERVICE_NAME, + LoggerServiceName.Checkin_VLM.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CHECK_IN_VLM + + vlmId); vendorLicenseManager.checkin(vlmId, user); break; case Submit: + MDC.put(LoggerConstants.SERVICE_NAME, + LoggerServiceName.Submit_VLM.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.SUBMIT_VLM + + vlmId); vendorLicenseManager.submit(vlmId, user); break; default: } - return Response.ok().build(); - } + return Response.ok().build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml index 9e84bf74c4..395c185f09 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml @@ -2,6 +2,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <artifactId>vendor-license-rest-types</artifactId> + <name>vendor-license-rest-types</name> + <parent> <groupId>org.openecomp.sdc.onboarding</groupId> <artifactId>vendor-license-rest</artifactId> @@ -9,11 +12,6 @@ <relativePath>../</relativePath> </parent> - <artifactId>vendor-license-rest-types</artifactId> - <name>vendor-license-rest-types</name> - - - <dependencies> <dependency> <groupId>org.openecomp.sdc</groupId> @@ -27,4 +25,4 @@ </dependency> </dependencies> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml.versionsBackup new file mode 100644 index 0000000000..d24c315f39 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-license-rest/vendor-license-rest-types/pom.xml.versionsBackup @@ -0,0 +1,29 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>vendor-license-rest-types</artifactId> + <name>vendor-license-rest-types</name> + <version>1.0-SNAPSHOT</version> + + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-license-rest</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-license-manager</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + +</project>
\ No newline at end of file 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 a1d1edddcf..aebb171b8e 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 @@ -23,10 +23,8 @@ package org.openecomp.sdcrests.vendorlicense.types; import io.swagger.annotations.ApiModel; import java.util.Set; - import javax.validation.constraints.Size; - @ApiModel(value = "FeatureGroupEntity") public class FeatureGroupEntityDto extends FeatureGroupDescriptorDto { private String 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/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 b0a8f65995..7c9f03dc91 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 @@ -26,7 +26,6 @@ import io.swagger.annotations.ApiModel; import java.util.Set; import javax.validation.constraints.Size; - @ApiModel(value = "LicenseAgreementEntity") public class LicenseAgreementEntityDto extends LicenseAgreementDescriptorDto { private String 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/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 5a88e4c72f..6039a810ba 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 @@ -28,7 +28,6 @@ import java.util.Set; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; - @GroupSequenceProvider(value = MultiChoiceOrOtherSequenceProvider.class) public class MultiChoiceOrOtherDto<E extends Enum<E>> { @NotNull 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 6c10f8fbe2..e8a900a82b 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 @@ -22,18 +22,18 @@ package org.openecomp.sdcrests.vendorlicense.types; import io.swagger.annotations.ApiModel; import org.openecomp.sdc.versioning.dao.types.VersionStatus; - +import org.openecomp.sdcrests.common.types.VersionDto; import java.util.List; @ApiModel(value = "VendorLicenseModelEntity") public class VendorLicenseModelEntityDto extends VendorLicenseModelRequestDto { private String id; - private String version; + private VersionDto version; private VersionStatus status; private String lockingUser; - private List<String> viewableVersions; - private List<String> finalVersions; + private List<VersionDto> viewableVersions; + private List<VersionDto> finalVersions; public String getId() { return id; @@ -43,11 +43,11 @@ public class VendorLicenseModelEntityDto extends VendorLicenseModelRequestDto { this.id = id; } - public String getVersion() { + public VersionDto getVersion() { return version; } - public void setVersion(String version) { + public void setVersion(VersionDto version) { this.version = version; } @@ -67,19 +67,19 @@ public class VendorLicenseModelEntityDto extends VendorLicenseModelRequestDto { this.lockingUser = lockingUser; } - public List<String> getViewableVersions() { + public List<VersionDto> getViewableVersions() { return viewableVersions; } - public void setViewableVersions(List<String> viewableVersions) { + public void setViewableVersions(List<VersionDto> viewableVersions) { this.viewableVersions = viewableVersions; } - public List<String> getFinalVersions() { + public List<VersionDto> getFinalVersions() { return finalVersions; } - public void setFinalVersions(List<String> finalVersions) { + public void setFinalVersions(List<VersionDto> finalVersions) { this.finalVersions = finalVersions; } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml index de416b2d47..eb7fe70691 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml @@ -3,6 +3,10 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-software-products-rest</artifactId> + <name>vendor-software-products-rest</name> + <packaging>pom</packaging> <parent> <groupId>org.openecomp.sdc</groupId> @@ -10,14 +14,8 @@ <version>1.1.0-SNAPSHOT</version> </parent> - <groupId>org.openecomp.sdc.onboarding</groupId> - <artifactId>vendor-software-products-rest</artifactId> - <name>vendor-software-products-rest</name> - <packaging>pom</packaging> - - <modules> <module>/vendor-software-products-rest-services</module> <module>/vendor-software-products-rest-types</module> </modules> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml.versionsBackup new file mode 100644 index 0000000000..074c8d9e10 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/pom.xml.versionsBackup @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-software-products-rest</artifactId> + <name>vendor-software-products-rest</name> + <version>1.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <parent> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-rest-webapp</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + <modules> + <module>/vendor-software-products-rest-services</module> + <module>/vendor-software-products-rest-types</module> + </modules> +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml index d0458bf89d..f146881751 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml @@ -4,15 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <artifactId>vendor-software-products-rest-services</artifactId> + <parent> <groupId>org.openecomp.sdc.onboarding</groupId> <artifactId>vendor-software-products-rest</artifactId> <version>1.1.0-SNAPSHOT</version> </parent> - <artifactId>vendor-software-products-rest-services</artifactId> - - <dependencies> <dependency> <groupId>org.springframework</groupId> @@ -46,26 +45,19 @@ <artifactId>cxf-rt-frontend-jaxrs</artifactId> <version>${cxf.version}</version> </dependency> - <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>${http.client.version}</version> </dependency> - <dependency> - <groupId>javax.ws.rs</groupId> - <artifactId>javax.ws.rs-api</artifactId> - <version>${ws.rs.version}</version> - </dependency> - <!-- Other Stuff--> - <dependency> + <!--dependency> <groupId>cglib</groupId> <artifactId>cglib-nodep</artifactId> <version>${cglib.nodep.version}</version> <scope>runtime</scope> - </dependency> + </dependency--> <!-- Java Stuff --> <dependency> @@ -82,7 +74,7 @@ <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-core</artifactId> - <version>1.19.1</version> + <version>${jersey.core.version}</version> <exclusions> <exclusion> <groupId>javax.ws.rs</groupId> @@ -93,39 +85,51 @@ <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-annotations</artifactId> - <version>1.5.3</version> - </dependency> - <dependency> - <groupId>org.openecomp.sdc.onboarding</groupId> - <artifactId>vendor-software-products-rest-types</artifactId> - <version>${project.version}</version> + <version>${swagger.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> - <version>2.7.4</version> + <version>${jackson.annotations.version}</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.dataformat</groupId> <artifactId>jackson-dataformat-xml</artifactId> - <version>2.7.4</version> + <version>${jackson.dataformat.version}</version> </dependency> <dependency> <groupId>org.codehaus.woodstox</groupId> <artifactId>woodstox-core-asl</artifactId> - <version>4.4.1</version> + <version>${woodstox.version}</version> </dependency> - <dependency> <groupId>org.openecomp.sdc</groupId> <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> <version>${project.version}</version> </dependency> - - + <dependency> + <groupId>com.sun.jersey.contribs</groupId> + <artifactId>jersey-multipart</artifactId> + <version>${jersey.multipart.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-software-products-rest-types</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-activity-log-manager</artifactId> + <version>${project.version}</version> + </dependency> </dependencies> - <build> <plugins> <plugin> @@ -138,7 +142,12 @@ <skipTests>true</skipTests> </configuration> </plugin> + <!-- Error codes generator plugin --> + <!--plugin> + <groupId>org.openecomp.nfv.tools</groupId> + <artifactId>error-codes-maven-plugin</artifactId> + </plugin--> </plugins> </build> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml.versionsBackup new file mode 100644 index 0000000000..ba2814613e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/pom.xml.versionsBackup @@ -0,0 +1,153 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>vendor-software-products-rest-services</artifactId> + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-software-products-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <dependencies> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context-support</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${spring.framework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-beans</artifactId> + <version>${spring.framework.version}</version> + </dependency> + + <!-- CXF --> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-frontend-jaxrs</artifactId> + <version>${cxf.version}</version> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>${http.client.version}</version> + </dependency> + + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + + <!-- Other Stuff--> + <!--dependency> + <groupId>cglib</groupId> + <artifactId>cglib-nodep</artifactId> + <version>${cglib.nodep.version}</version> + <scope>runtime</scope> + </dependency--> + + <!-- Java Stuff --> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>${javax.inject.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>javax.ws.rs</groupId> + <artifactId>javax.ws.rs-api</artifactId> + <version>${ws.rs.version}</version> + </dependency> + <dependency> + <groupId>com.sun.jersey</groupId> + <artifactId>jersey-core</artifactId> + <version>1.19.1</version> + <exclusions> + <exclusion> + <groupId>javax.ws.rs</groupId> + <artifactId>jsr311-api</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>1.5.3</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-software-products-rest-types</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + <version>2.7.4</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-xml</artifactId> + <version>2.7.4</version> + </dependency> + <dependency> + <groupId>org.codehaus.woodstox</groupId> + <artifactId>woodstox-core-asl</artifactId> + <version>4.4.1</version> + </dependency> + + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>com.sun.jersey.contribs</groupId> + <artifactId>jersey-multipart</artifactId> + <version>1.18.1</version> + <scope>provided</scope> + </dependency> + + + </dependencies> + + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <includes> + <include>test/core/unittest/offline/**</include> + </includes> + <skipTests>true</skipTests> + </configuration> + </plugin> + <!-- Error codes generator plugin --> + <!--plugin> + <groupId>org.openecomp.nfv.tools</groupId> + <artifactId>error-codes-maven-plugin</artifactId> + </plugin--> + </plugins> + </build> + +</project>
\ No newline at end of file diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencyModels.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencyModels.java new file mode 100644 index 0000000000..5df05d1cf1 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentDependencyModels.java @@ -0,0 +1,55 @@ +package org.openecomp.sdcrests.vsp.rest; + +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModelRequestDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + + +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; + +import java.util.List; + +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/component-dependency-model") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Product Component Dependency Model") +@Validated +public interface ComponentDependencyModels extends VspEntities { + + @POST + @Path("/") + @ApiOperation(value = "Create a vendor software product component dependency model") + Response create(@Valid ComponentDependencyModelRequestDto request, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); + + @GET + @Path("/") + @ApiOperation(value = "Get component dependency Model for vendor software product", + response = ComponentDependencyModelRequestDto.class, + responseContainer = "List") + Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") + String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) + String user); +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java index 3fae16cf7f..ca50ef1426 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentProcesses.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,7 +20,7 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; import io.swagger.annotations.Api; @@ -49,24 +49,22 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@Path("/v1.0/vendor-software-products/{vspId}/components/{componentId}/processes") +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/processes") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Api(value = "Vendor Software Product Component Processes") @Validated -public interface ComponentProcesses { +public interface ComponentProcesses extends VspEntities { @GET @Path("/") @ApiOperation(value = "List vendor software product component processes", response = ProcessEntityDto.class, responseContainer = "List") Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @@ -75,18 +73,20 @@ public interface ComponentProcesses { responseContainer = "List") Response deleteList( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/") @ApiOperation(value = "Create a vendor software product process") Response create(@Valid ProcessRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -94,25 +94,24 @@ public interface ComponentProcesses { @ApiOperation(value = "Get vendor software product process", response = ProcessEntityDto.class) Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{processId}") @ApiOperation(value = "Delete vendor software product process") Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @@ -120,11 +119,12 @@ public interface ComponentProcesses { @ApiOperation(value = "Update vendor software product process") Response update(@Valid ProcessRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -133,36 +133,36 @@ public interface ComponentProcesses { @ApiOperation(value = "Get vendor software product process uploaded file") Response getUploadedFile( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{processId}/upload") @ApiOperation(value = "Delete vendor software product process uploaded file") Response deleteUploadedFile( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/{processId}/upload") @Consumes(MediaType.MULTIPART_FORM_DATA) @ApiOperation(value = "Update vendor software product process upload") Response uploadFile(@Multipart("upload") Attachment attachment, - @ApiParam(value = "Vendor software product Id") @PathParam("vspId") - String vspId, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentUploads.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentUploads.java index c7ad2f7fe5..313ae24e95 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentUploads.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/ComponentUploads.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,7 +20,7 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; import io.swagger.annotations.Api; @@ -43,62 +43,66 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; - -@Path("/v1.0/vendor-software-products/{vspId}/components/{componentId}/monitors") +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/monitors") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Api(value = "Vendor Software Product Component MIB Uploads") @Validated -public interface ComponentUploads { +public interface ComponentUploads extends VspEntities { @POST @Path("/snmp-trap/upload") @Consumes(MediaType.MULTIPART_FORM_DATA) - @ApiOperation(value = "Upload vendor software product MIB Trap Definitions file") + @ApiOperation(value = "Upload vendor software product MIB SNMP_TRAP Definitions file") Response uploadTrapMibFile(@Multipart("upload") Attachment attachment, - @ApiParam(value = "Vendor software product Id") @PathParam("vspId") - String vspId, - @ApiParam(value = "Vendor software product component Id") - @PathParam("componentId") String componentId, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Component Id") @PathParam("componentId") String + componentId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/snmp-trap") - @ApiOperation(value = "Delete vendor software product MIB Trap Definitions file") + @ApiOperation(value = "Delete vendor software product MIB SNMP_TRAP Definitions file") Response deleteTrapMibFile( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Component Id") @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/snmp/upload") @Consumes(MediaType.MULTIPART_FORM_DATA) - @ApiOperation(value = "Upload vendor software product MIB Poll Definitions file") + @ApiOperation(value = "Upload vendor software product MIB SNMP_POLL Definitions file") Response uploadPollMibFile(@Multipart("upload") Attachment attachment, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/snmp") - @ApiOperation(value = "Delete vendor software product MIB Poll Definitions file") + @ApiOperation(value = "Delete vendor software product MIB SNMP_POLL Definitions file") Response deletePollMibFile( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + // TODO: 2/27/2017 add version @GET @Path("/snmp/") @ApiOperation(value = "Get the filenames of uploaded MIB definitions", response = MibUploadStatusDto.class) Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Components.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Components.java index 949a40cfbb..cff69d2c01 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Components.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Components.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,14 +20,10 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; -import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; @@ -36,7 +32,6 @@ import org.springframework.validation.annotation.Validated; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -46,26 +41,26 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@Path("/v1.0/vendor-software-products/{vspId}/components") +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Api(value = "Vendor Software Product Components") @Validated -public interface Components { +public interface Components extends VspEntities { @GET @Path("/") @ApiOperation(value = "List vendor software product components", response = ComponentDto.class, responseContainer = "List") Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @@ -74,14 +69,16 @@ public interface Components { responseContainer = "List") Response deleteList( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/") @ApiOperation(value = "Create a vendor software product component") Response create(@Valid ComponentRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -90,21 +87,20 @@ public interface Components { response = ComponentData.class, responseContainer = "CompositionEntityResponse") Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{componentId}") @ApiOperation(value = "Delete vendor software product component") Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @@ -112,9 +108,10 @@ public interface Components { @ApiOperation(value = "Update vendor software product component") Response update(@Valid ComponentRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -123,11 +120,10 @@ public interface Components { response = QuestionnaireResponseDto.class) Response getQuestionnaire( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") - String componentId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product component Id") + @PathParam("componentId") String componentId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @Path("/{componentId}/questionnaire") @@ -135,8 +131,10 @@ public interface Components { Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") + String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Networks.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Networks.java index 5c7c9d7bd8..fae6510bc2 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Networks.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Networks.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,20 +20,15 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; -import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkRequestDto; import org.springframework.validation.annotation.Validated; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -43,26 +38,26 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@Path("/v1.0/vendor-software-products/{vspId}/networks") +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/networks") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Api(value = "Vendor Software Product Networks") @Validated -public interface Networks { +public interface Networks extends VspEntities { @GET @Path("/") @ApiOperation(value = "List vendor software product networks", response = NetworkDto.class, responseContainer = "List") Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @@ -70,7 +65,8 @@ public interface Networks { @ApiOperation(value = "Create a vendor software product network") Response create(@Valid NetworkRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -78,21 +74,20 @@ public interface Networks { @ApiOperation(value = "Get vendor software product network", response = NetworkDto.class) Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @ApiParam(value = "Vendor software product network Id") @PathParam("networkId") - String networkId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @ApiParam(value = "Vendor software product network Id") + @PathParam("networkId") String networkId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{networkId}") @ApiOperation(value = "Delete vendor software product network") Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product network Id") @PathParam("networkId") String networkId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @@ -100,8 +95,9 @@ public interface Networks { @ApiOperation(value = "Update vendor software product network") Response update(@Valid NetworkRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product network Id") @PathParam("networkId") String networkId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java index 8cf26a405b..c29966b54b 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Nics.java @@ -20,7 +20,7 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; import io.swagger.annotations.Api; @@ -49,24 +49,22 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@Path("/v1.0/vendor-software-products/{vspId}/components/{componentId}/nics") +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/components/{componentId}/nics") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Api(value = "Vendor Software Product Component NICs") @Validated -public interface Nics { +public interface Nics extends VspEntities { @GET @Path("/") @ApiOperation(value = "List vendor software product component NICs", response = NicDto.class, responseContainer = "List") Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @@ -74,9 +72,10 @@ public interface Nics { @ApiOperation(value = "Create a vendor software product NIC") Response create(@Valid NicRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -84,24 +83,23 @@ public interface Nics { @ApiOperation(value = "Get vendor software product NIC", response = NicDto.class) Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product NIC Id") @PathParam("nicId") String nicId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{nicId}") @ApiOperation(value = "Delete vendor software product NIC") Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product NIC Id") @PathParam("nicId") String nicId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @@ -109,11 +107,12 @@ public interface Nics { @ApiOperation(value = "Update vendor software product NIC") Response update(@Valid NicRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product NIC Id") @PathParam("nicId") String nicId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -122,12 +121,11 @@ public interface Nics { response = QuestionnaireResponseDto.class) Response getQuestionnaire( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product NIC Id") @PathParam("nicId") String nicId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @Path("/{nicId}/questionnaire") @@ -135,10 +133,11 @@ public interface Nics { Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product component Id") @PathParam("componentId") String componentId, @ApiParam(value = "Vendor software product NIC Id") @PathParam("nicId") String nicId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java new file mode 100644 index 0000000000..fbf29185e3 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/OrchestrationTemplateCandidate.java @@ -0,0 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import org.openecomp.sdc.vendorsoftwareproduct.types.FileDataStructureDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; +import javax.validation.constraints.NotNull; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; + +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/orchestration-template-candidate") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Orchestration Template Candidate") +@Validated +public interface OrchestrationTemplateCandidate extends VspEntities { + + @POST + @Path("/") + @Consumes(MediaType.MULTIPART_FORM_DATA) + Response upload( + @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @Multipart("upload") InputStream heatFileToUpload, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); + + @GET + @Path("/") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + @ApiOperation(value = "Get uploaded candidate HEAT file", + notes = "Downloads in process candidate HEAT file", + response = File.class) + Response get( + @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws IOException; + + @PUT + @Path("/process") + @ApiOperation(value = "process Orchestration Template Candidate", + response = UploadFileResponseDto.class) + Response process( + @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws InvocationTargetException, IllegalAccessException; + + @PUT + @Path("/manifest") + @ApiOperation(value = "Update an existing vendor software product") + Response updateFilesDataStructure( + @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @Valid FileDataStructureDto fileDataStructureDto, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws Exception; + + @GET + @Path("/manifest") + @ApiOperation(value = "Get uploaded HEAT file files data structure", + notes = "Downloads the latest HEAT package", + response = FileDataStructureDto.class) + Response getFilesDataStructure( + @PathParam("vspId") String vspId, + @ApiParam(value = "Version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws Exception; + +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java index b5c74587e4..93dcbc4e32 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/Processes.java @@ -20,9 +20,6 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -31,26 +28,19 @@ import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; - import org.springframework.validation.annotation.Validated; import javax.validation.Valid; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -@Path("/v1.0/vendor-software-products/{vspId}/processes") +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +@Path("/v1.0/vendor-software-products/{vspId}/versions/{versionId}/processes") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Api(value = "Vendor Software Product Processes") @@ -62,10 +52,8 @@ public interface Processes { response = ProcessEntityDto.class, responseContainer = "List") Response list(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @@ -74,14 +62,16 @@ public interface Processes { responseContainer = "List") Response deleteList( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/") @ApiOperation(value = "Create a vendor software product process") Response create(@Valid ProcessRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -89,21 +79,20 @@ public interface Processes { @ApiOperation(value = "Get vendor software product process", response = ProcessEntityDto.class) Response get(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{processId}") @ApiOperation(value = "Delete vendor software product process") Response delete(@ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT @@ -111,9 +100,10 @@ public interface Processes { @ApiOperation(value = "Update vendor software product process") Response update(@Valid ProcessRequestDto request, @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @@ -122,30 +112,30 @@ public interface Processes { @ApiOperation(value = "Get vendor software product process uploaded file") Response getUploadedFile( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @Pattern(regexp = Version.VERSION_REGEX, message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{processId}/upload") @ApiOperation(value = "Delete vendor software product process uploaded file") Response deleteUploadedFile( @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) String user); + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); @POST @Path("/{processId}/upload") @Consumes(MediaType.MULTIPART_FORM_DATA) @ApiOperation(value = "Update vendor software product process upload") Response uploadFile(@Multipart("upload") Attachment attachment, - @ApiParam(value = "Vendor software product Id") @PathParam("vspId") - String vspId, + @ApiParam(value = "Vendor software product Id") @PathParam("vspId") String vspId, + @ApiParam(value = "Vendor software product version Id") @PathParam("versionId") String versionId, @ApiParam(value = "Vendor software product process Id") @PathParam("processId") String processId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java index 259ef723c6..3ead86dc14 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProducts.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,127 +20,105 @@ package org.openecomp.sdcrests.vsp.rest; -import static org.openecomp.sdcrests.common.RestConstants.USER_HEADER_PARAM; -import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; - import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; - -import org.apache.cxf.jaxrs.ext.multipart.Multipart; -import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; import org.openecomp.sdcrests.vendorsoftwareproducts.types.validation.IsValidJson; import org.springframework.validation.annotation.Validated; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import java.io.File; +import java.io.IOException; +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; @Path("/v1.0/vendor-software-products") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @Api(value = "Vendor Software Products") @Validated -public interface VendorSoftwareProducts { +public interface VendorSoftwareProducts extends VspEntities { @POST @Path("/") @ApiOperation(value = "Create a new vendor software product", response = VspCreationDto.class) - Response createNewVsp(@Valid VspDescriptionDto vspDescriptionDto, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) - String user); + Response createVsp(@Valid VspDescriptionDto vspDescriptionDto, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET @Path("/") @ApiOperation(value = "Get list of vendor software products and their description", responseContainer = "List") - Response getVspList(@ApiParam( + Response listVsps(@ApiParam( value = "Currently supported values: 'Final' - only vendor software products with final " - + "version will be return - with their latest final version") - @QueryParam("versionFilter") String versionFilter, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) - String user); + + " version will be return - with their latest final version") + @QueryParam("versionFilter") String versionFilter, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); - @GET - @Path("/packages") - @ApiOperation(value = "Get list of translated CSAR files details", - response = PackageInfoDto.class, - responseContainer = "List") - Response listPackages(@ApiParam("Category") @QueryParam("category") String category, - @ApiParam("Sub-category") @QueryParam("subCategory") String subCategory, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) - String user); @GET - @Path("/{vspId}") + @Path("/{vspId}/versions/{versionId}") @ApiOperation(value = "Get details of a vendor software product") - Response getVspDetails(@PathParam("vspId") String vspId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") - String version, - @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + Response getVsp(@PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT - @Path("/{vspId}") + @Path("/{vspId}/versions/{versionId}") @ApiOperation(value = "Update an existing vendor software product") - Response updateVsp(@PathParam("vspId") String vspId, @Valid VspDescriptionDto vspDescriptionDto, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) - String user); + Response updateVsp(@PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, + @Valid VspDescriptionDto vspDescriptionDto, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); @DELETE @Path("/{vspId}") @ApiOperation(value = "Deletes vendor software product by given id") Response deleteVsp(@PathParam("vspId") String vspId, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) - String user); + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); - @POST - @Path("{vspId}/upload") - @Consumes(MediaType.MULTIPART_FORM_DATA) - @ApiOperation(value = "Uploads a HEAT package to translate", - response = UploadFileResponseDto.class) - Response uploadFile(@PathParam("vspId") String vspId, - @Multipart("upload") InputStream heatFileToUpload, - @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_HEADER_PARAM) - String user); + @GET + @Path("/packages") + @ApiOperation(value = "Get list of translated CSAR files details", + response = PackageInfoDto.class, + responseContainer = "List") + Response listPackages(@ApiParam("Category") @QueryParam("category") String category, + @ApiParam("Sub-category") @QueryParam("subCategory") String subCategory, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET - @Path("/{vspId}/downloadHeat") + @Path("/{vspId}/versions/{versionId}/orchestration-template") @Produces(MediaType.APPLICATION_OCTET_STREAM) - @ApiOperation(value = "Get uploaded HEAT file", + @ApiOperation(value = "Get Orchestration Template (HEAT) file", notes = "Downloads the latest HEAT package", response = File.class) - Response getLatestHeatPackage(@PathParam("vspId") String vspId, - /*@NotNull(message = USER_MISSING_ERROR_MSG)*/ - @HeaderParam(USER_HEADER_PARAM) String user); + Response getOrchestrationTemplate( + @PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, + @HeaderParam(USER_ID_HEADER_PARAM) String user); + @GET + @Path("/validation-vsp") + Response getValidationVsp( + @NotNull(message = USER_MISSING_ERROR_MSG) @HeaderParam(USER_ID_HEADER_PARAM) String user) + throws Exception; + @PUT - @Path("/{vspId}/actions") + @Path("/{vspId}/versions/{versionId}/actions") @ApiOperation(value = "Actions on a vendor software product", notes = "Performs one of the following actions on a vendor software product: |" + "Checkout: Locks it for edits by other users. Only the locking user sees the edited " @@ -149,14 +127,11 @@ public interface VendorSoftwareProducts { + "Checkin: Unlocks it and activates the edited version to all users.| " + "Submit: Finalize its active version.|" + "Create_Package: Creates a CSAR zip file.|") - /*@ApiResponses(value = { - @ApiResponse(code = 200, message = "Action succeeded"), - @ApiResponse(code = 417, message = "Validation before submit has failed", - response = ValidationResponseDto.class)})*/ Response actOnVendorSoftwareProduct(@PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, VersionSoftwareProductActionRequestDto request, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user) + @HeaderParam(USER_ID_HEADER_PARAM) String user) throws IOException; @GET @@ -166,28 +141,46 @@ public interface VendorSoftwareProducts { notes = "Exports translated file to a zip file", response = File.class) Response getTranslatedFile(@PathParam("vspId") String vspId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) @QueryParam("version") String version, - /*@NotNull(message = USER_MISSING_ERROR_MSG)*/ - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @GET - @Path("/{vspId}/questionnaire") + @Path("/{vspId}/versions/{versionId}/questionnaire") @ApiOperation(value = "Get vendor software product questionnaire", response = QuestionnaireResponseDto.class) Response getQuestionnaire(@PathParam("vspId") String vspId, - @Pattern(regexp = Version.VERSION_REGEX, - message = Version.VERSION_STRING_VIOLATION_MSG) - @QueryParam("version") String version, + @PathParam("versionId") String versionId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); @PUT - @Path("/{vspId}/questionnaire") + @Path("/{vspId}/versions/{versionId}/questionnaire") @ApiOperation(value = "Update vendor software product questionnaire") Response updateQuestionnaire(@NotNull @IsValidJson String questionnaireData, @PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, @NotNull(message = USER_MISSING_ERROR_MSG) - @HeaderParam(USER_HEADER_PARAM) String user); + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + + @PUT + @Path("/{vspId}/versions/{versionId}/heal") + @ApiOperation(value = "Checkout and heal vendor software product questionnaire", + response = QuestionnaireResponseDto.class) + Response heal(@PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + + @GET + @Path("/{vspId}/versions/{versionId}/vspInformationArtifact") + @Produces(MediaType.TEXT_PLAIN) + @ApiOperation(value = "Get vendor software product information artifact for specified version", + response = File.class) + Response getVspInformationArtifact(@PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); + } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProductsForSwaggerFileUpload.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProductsForSwaggerFileUpload.java new file mode 100644 index 0000000000..eb70394b28 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VendorSoftwareProductsForSwaggerFileUpload.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest; + +import com.sun.jersey.multipart.FormDataParam; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; +import org.springframework.validation.annotation.Validated; + +import javax.validation.constraints.NotNull; +import javax.ws.rs.*; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.InputStream; + +import static org.openecomp.sdcrests.common.RestConstants.USER_ID_HEADER_PARAM; +import static org.openecomp.sdcrests.common.RestConstants.USER_MISSING_ERROR_MSG; + +@Path("/v1.0/vendor-software-products") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +@Api(value = "Vendor Software Products") +@Validated +public interface VendorSoftwareProductsForSwaggerFileUpload { + + + + @POST + @Path("/{vspId}/versions/{versionId}/orchestration-template-candidate") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @ApiOperation(value = "Uploads a HEAT package to translate", + response = UploadFileResponseDto.class) + Response uploadOrchestrationTemplateCandidate(@PathParam("vspId") String vspId, + @PathParam("versionId") String versionId, + @FormDataParam("upload") + InputStream heatFileToUpload, + @NotNull(message = USER_MISSING_ERROR_MSG) + @HeaderParam(USER_ID_HEADER_PARAM) String user); + + } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VspEntities.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VspEntities.java new file mode 100644 index 0000000000..bd53305e33 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/VspEntities.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest; + +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; +import org.openecomp.sdc.versioning.VersioningManager; +import org.openecomp.sdc.versioning.VersioningManagerFactory; +import org.openecomp.sdc.versioning.VersioningUtil; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionInfo; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; + +public interface VspEntities { + VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface(); + + default Version resolveVspVersion(String vspId, String version, String user, + VersionableEntityAction action) { + return VersioningUtil + .resolveVersion(Version.valueOf(version), getVersionInfo(vspId, action, user), user); + } + + default VersionInfo getVersionInfo(String vendorSoftwareProductId, VersionableEntityAction action, + String user) { + return versioningManager.getEntityVersionInfo( + VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, + vendorSoftwareProductId, user, action); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDto.java index e448ed6ca7..b669830bc7 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDataToComponentDto.java @@ -30,6 +30,8 @@ public class MapComponentDataToComponentDto extends MappingBase<ComponentData, C target.setName(source.getName()); target.setDisplayName( source.getDisplayName() == null ? source.getName() : source.getDisplayName()); + target.setVfcCode( + source.getVfcCode() == null ? target.getDisplayName() : source.getVfcCode()); target.setDescription(source.getDescription()); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelEntityToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelEntityToDto.java new file mode 100644 index 0000000000..0c923fe82b --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelEntityToDto.java @@ -0,0 +1,25 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerTragetServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; +import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRelationType; + +public class MapComponentDependencyModelEntityToDto extends + MappingBase<ComponentDependencyModelEntity, ComponentDependencyModel> { + + @Override + public void doMapping(ComponentDependencyModelEntity source, + ComponentDependencyModel target) { + target.setSourceId(source.getSourceComponentId()); + target.setTargetId(source.getTargetComponentId()); + target.setRelationType(source.getRelation()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntity.java new file mode 100644 index 0000000000..e51ccbd937 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentDependencyModelRequestToEntity.java @@ -0,0 +1,36 @@ +package org.openecomp.sdcrests.vsp.rest.mapping; + + +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.datatypes.error.ErrorLevel; +import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerTragetServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; +import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder; +import org.openecomp.sdcrests.mapping.MappingBase; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRelationType; + +public class MapComponentDependencyModelRequestToEntity extends + MappingBase<ComponentDependencyModel, ComponentDependencyModelEntity> { + + @Override + public void doMapping(ComponentDependencyModel source, + ComponentDependencyModelEntity target) { + target.setSourceComponentId(source.getSourceId()); + target.setTargetComponentId(source.getTargetId()); + try { + ComponentRelationType.valueOf(source.getRelationType()); + target.setRelation(source.getRelationType()); + } catch (IllegalArgumentException exception) { + ErrorCode errorCode = + ComponentDependencyModelErrorBuilder.getInvalidRelationTypeErrorBuilder(); + MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB, + LoggerTragetServiceName.CREATE_COMPONENT_DEPENDENCY_MODEL, ErrorLevel.ERROR.name(), + errorCode.id(), errorCode.message() ); + throw new CoreException(errorCode); + } + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentRequestDtoToComponentEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentRequestDtoToComponentEntity.java index ce9e32770c..f61ee0d4ab 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentRequestDtoToComponentEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapComponentRequestDtoToComponentEntity.java @@ -32,6 +32,7 @@ public class MapComponentRequestDtoToComponentEntity ComponentData component = new ComponentData(); component.setName(source.getName()); component.setDisplayName(source.getDisplayName()); + component.setVfcCode(source.getVfcCode()); component.setDescription(source.getDescription()); target.setComponentCompositionData(component); } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDto.java index b5b7ccdfee..f7ecc243f1 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityResponseToDto.java @@ -26,8 +26,8 @@ import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionDataEntityDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; -public class MapCompositionEntityResponseToDto<S extends CompositionDataEntity, - T extends CompositionDataEntityDto, M extends MappingBase<S, T>> +public class MapCompositionEntityResponseToDto<S extends CompositionDataEntity, T extends + CompositionDataEntityDto, M extends MappingBase<S, T>> extends MappingBase<CompositionEntityResponse<S>, CompositionEntityResponseDto<T>> { private M dataMapper; private Class<T> targetDataClass; diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDto.java index cb726dfc79..ee7a9f446e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapCompositionEntityValidationDataToDto.java @@ -21,7 +21,7 @@ package org.openecomp.sdcrests.vsp.rest.mapping; import org.apache.commons.collections4.CollectionUtils; -import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityValidationData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; @@ -34,6 +34,7 @@ public class MapCompositionEntityValidationDataToDto CompositionEntityValidationDataDto target) { target.setEntityType(source.getEntityType()); target.setEntityId(source.getEntityId()); + target.setEntityName(source.getEntityName()); target.setErrors(source.getErrors()); if (CollectionUtils.isNotEmpty(source.getSubEntitiesValidationData())) { target.setSubEntitiesValidationData(source.getSubEntitiesValidationData().stream() diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToGetFileDataStructureResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToGetFileDataStructureResponseDto.java new file mode 100644 index 0000000000..b7d4670203 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapFilesDataStructureToGetFileDataStructureResponseDto.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vsp.rest.mapping; + + +import org.openecomp.sdc.vendorsoftwareproduct.types.GetFileDataStructureResponseDTO; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; +import org.openecomp.sdcrests.mapping.MappingBase; + +/** + * Created by TALIO on 4/27/2016. + */ +public class MapFilesDataStructureToGetFileDataStructureResponseDto + extends MappingBase<FilesDataStructure, GetFileDataStructureResponseDTO> { + @Override + public void doMapping(FilesDataStructure source, GetFileDataStructureResponseDTO target) { + target.setModules(source.getModules()); + target.setArtifacts(source.getArtifacts()); + target.setUnassigned(source.getUnassigned()); + target.setNested(source.getNested()); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java index 9cd365480e..34616b4306 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapPackageInfoToPackageInfoDto.java @@ -24,10 +24,12 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; +/** + * Created by TALIO on 4/25/2016. + */ public class MapPackageInfoToPackageInfoDto extends MappingBase<PackageInfo, PackageInfoDto> { @Override public void doMapping(PackageInfo source, PackageInfoDto target) { - target.setDisplayName(source.getDisplayName()); target.setVspName(source.getVspName()); target.setPackageId(source.getVspId()); target.setDescription(source.getVspDescription()); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessEntityToProcessEntityDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessEntityToProcessEntityDto.java index 5842a30b70..96a67a9d87 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessEntityToProcessEntityDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessEntityToProcessEntityDto.java @@ -31,6 +31,7 @@ public class MapProcessEntityToProcessEntityDto target.setId(source.getId()); target.setName(source.getName()); target.setDescription(source.getDescription()); + target.setType(source.getType()); target.setArtifactName(source.getArtifactName()); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessRequestDtoToProcessEntity.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessRequestDtoToProcessEntity.java index 1fd35d1960..d1a28d7145 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessRequestDtoToProcessEntity.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapProcessRequestDtoToProcessEntity.java @@ -30,5 +30,6 @@ public class MapProcessRequestDtoToProcessEntity public void doMapping(ProcessRequestDto source, ProcessEntity target) { target.setName(source.getName()); target.setDescription(source.getDescription()); + target.setType(source.getType()); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireResponseToQuestionnaireResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireResponseToQuestionnaireResponseDto.java index 23fdf385e4..52252c0425 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireResponseToQuestionnaireResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapQuestionnaireResponseToQuestionnaireResponseDto.java @@ -31,5 +31,6 @@ public class MapQuestionnaireResponseToQuestionnaireResponseDto public void doMapping(QuestionnaireResponse source, QuestionnaireResponseDto target) { target.setData(source.getData()); target.setSchema(source.getSchema()); + target.setErrorMessage(source.getErrorMessage()); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapUploadFileResponseToUploadFileResponseDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapUploadFileResponseToUploadFileResponseDto.java index 29b6701413..cccfd02371 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapUploadFileResponseToUploadFileResponseDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapUploadFileResponseToUploadFileResponseDto.java @@ -25,12 +25,14 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; +/** + * Created by TALIO on 4/27/2016. + */ public class MapUploadFileResponseToUploadFileResponseDto extends MappingBase<UploadFileResponse, UploadFileResponseDto> { @Override public void doMapping(UploadFileResponse source, UploadFileResponseDto target) { target.setStatus(source.getStatus()); target.setErrors(source.getErrors()); - target.setFileNames(source.getFileNames()); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java index 68bc97d1a6..e6346c452d 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapValidationResponseToDto.java @@ -26,6 +26,7 @@ import org.openecomp.sdc.common.errors.ErrorCode; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult; import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdcrests.common.mapping.MapErrorCodeToDto; import org.openecomp.sdcrests.common.mapping.MapErrorMessageToDto; import org.openecomp.sdcrests.common.types.ErrorCodeDto; @@ -35,10 +36,12 @@ import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityVali import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireValidationResultDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto; - +import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; public class MapValidationResponseToDto @@ -60,9 +63,14 @@ public class MapValidationResponseToDto QuestionnaireValidationResultDto questionnaireValidationResultDto = new QuestionnaireValidationResultDto(); questionnaireValidationResultDto.setValid(questionnaireValidationResult.isValid()); - questionnaireValidationResultDto.setValidationData(new MapCompositionEntityValidationDataToDto() - .applyMapping(questionnaireValidationResult.getValidationData(), - CompositionEntityValidationDataDto.class)); + + Set<CompositionEntityValidationDataDto> validationDataDto = new HashSet<>(); + for(CompositionEntityValidationData validationData : questionnaireValidationResult.getValidationData()){ + validationDataDto.add(new MapCompositionEntityValidationDataToDto().applyMapping + (validationData, CompositionEntityValidationDataDto.class)); + } + + questionnaireValidationResultDto.setValidationData(validationDataDto); return questionnaireValidationResultDto; } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java index 9f03f7ff0d..6eca00e8aa 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVersionedVendorSoftwareProductInfoToVspDetailsDto.java @@ -24,7 +24,7 @@ import org.openecomp.core.utilities.CommonMethods; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData; import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo; -import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.common.types.VersionDto; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; @@ -38,14 +38,15 @@ public class MapVersionedVendorSoftwareProductInfoToVspDetailsDto VspDetails vsp = source.getVspDetails(); target.setId(vsp.getId()); - target.setVersion(vsp.getVersion().toString()); + target.setVersion(new VersionDto(vsp.getVersion().toString(), vsp.getVersion().toString())); target.setName(vsp.getName()); target.setDescription(vsp.getDescription()); target.setCategory(vsp.getCategory()); target.setSubCategory(vsp.getSubCategory()); target.setVendorId(vsp.getVendorId()); target.setVendorName(vsp.getVendorName()); - target.setLicensingVersion(vsp.getVlmVersion() == null ? null : vsp.getVlmVersion().toString()); + target.setLicensingVersion(vsp.getVlmVersion() == null ? null : new VersionDto(vsp.getVlmVersion().toString(), vsp.getVlmVersion().toString())); + target.setIsOldVersion("False"); if (vsp.getLicenseAgreement() != null || vsp.getFeatureGroups() != null) { LicensingData licensingData = new LicensingData(); @@ -61,13 +62,15 @@ public class MapVersionedVendorSoftwareProductInfoToVspDetailsDto if (!CommonMethods.isEmpty(source.getVersionInfo().getViewableVersions())) { target.setViewableVersions( - source.getVersionInfo().getViewableVersions().stream().map(Version::toString) + source.getVersionInfo().getViewableVersions().stream() + .map(version -> new VersionDto(version.toString(), version.toString())) .collect(Collectors.toList())); } if (!CommonMethods.isEmpty(source.getVersionInfo().getFinalVersions())) { target.setFinalVersions( - source.getVersionInfo().getFinalVersions().stream().map(Version::toString) + source.getVersionInfo().getFinalVersions().stream() + .map(version -> new VersionDto(version.toString(), version.toString())) .collect(Collectors.toList())); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java index 77093fe682..ec0843263a 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java @@ -23,11 +23,10 @@ package org.openecomp.sdcrests.vsp.rest.mapping; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData; import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdcrests.common.types.VersionDto; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; -import java.util.regex.Pattern; - public class MapVspDescriptionDtoToVspDetails extends MappingBase<VspDescriptionDto, VspDetails> { @Override @@ -40,11 +39,13 @@ public class MapVspDescriptionDtoToVspDetails extends MappingBase<VspDescription target.setVendorName(source.getVendorName()); target.setVendorId(source.getVendorId()); - String vlmVersion = source.getLicensingVersion(); + VersionDto vlmVersion = source.getLicensingVersion(); if (vlmVersion != null) { - target.setVlmVersion( - Pattern.compile(Version.VERSION_REGEX).matcher(vlmVersion).find() ? Version - .valueOf(vlmVersion) : null); + Version version = Version.valueOf(vlmVersion.getId()); + target.setVlmVersion(version); +// target.setVlmVersion( +// Pattern.compile(Version.VERSION_REGEX).matcher(vlmVersion.getId()).find() ? Version +// .valueOf(vlmVersion.getId()) : null); } LicensingData licensingData = source.getLicensingData(); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MspVspDetailsToVspCreationDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MspVspDetailsToVspCreationDto.java index a2de1741a3..5480dc13d5 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MspVspDetailsToVspCreationDto.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MspVspDetailsToVspCreationDto.java @@ -24,6 +24,9 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdcrests.mapping.MappingBase; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto; +/** + * Created by TALIO on 5/15/2016. + */ public class MspVspDetailsToVspCreationDto extends MappingBase<VspDetails, VspCreationDto> { @Override public void doMapping(VspDetails source, VspCreationDto target) { diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependencyModelsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependencyModelsImpl.java new file mode 100644 index 0000000000..4a23140c88 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentDependencyModelsImpl.java @@ -0,0 +1,78 @@ +package org.openecomp.sdcrests.vsp.rest.services; + +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManager; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModel; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDependencyModelRequestDto; +import org.openecomp.sdcrests.vsp.rest.ComponentDependencyModels; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDependencyModelEntityToDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapComponentDependencyModelRequestToEntity; + +import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import javax.inject.Named; +import javax.ws.rs.core.Response; + +@Named +@Service("componentDependencyModel") +@Scope(value = "prototype") +public class ComponentDependencyModelsImpl implements ComponentDependencyModels { + + private ComponentDependencyModelManager componentDependencyModelManager = + ComponentDependencyModelManagerFactory.getInstance().createInterface(); + + @Override + public Response create(ComponentDependencyModelRequestDto request, String vspId, + String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.CREATE_COMPONENT_DEPENDENCY_MODEL.toString()); + List<ComponentDependencyModelEntity> modelEntities = new + ArrayList<ComponentDependencyModelEntity>(); + + final Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + + if (request.getComponentDependencyModels() != null) { + for(ComponentDependencyModel model : request.getComponentDependencyModels()) { + ComponentDependencyModelEntity modelEntity = + new MapComponentDependencyModelRequestToEntity().applyMapping(model, + ComponentDependencyModelEntity.class); + + modelEntity.setVspId(vspId); + modelEntity.setVersion(version); + modelEntities.add(modelEntity); + } + } + + componentDependencyModelManager + .createComponentDependencyModel(modelEntities, vspId, version, user); + + return Response.ok().build(); + } + + @Override + public Response list(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.GET_COMPONENT_DEPENDENCY_MODEL.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + + Collection<ComponentDependencyModelEntity> componentDependencies = + componentDependencyModelManager.list(vspId, vspVersion, user); + + MapComponentDependencyModelEntityToDto mapper = new MapComponentDependencyModelEntityToDto(); + GenericCollectionWrapper<ComponentDependencyModel> results = new GenericCollectionWrapper + <ComponentDependencyModel>(); + for (ComponentDependencyModelEntity entity : componentDependencies) { + results.add(mapper.applyMapping(entity, ComponentDependencyModel.class)); + } + + return Response.ok(results).build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java index 2b16fea6c0..abcb3c5322 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentProcessesImpl.java @@ -21,9 +21,19 @@ package org.openecomp.sdcrests.vsp.rest.services; import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.messages.AuditMessages; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.ProcessManager; +import org.openecomp.sdc.vendorsoftwareproduct.ProcessManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity; import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessEntityDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; import org.openecomp.sdcrests.vsp.rest.ComponentProcesses; @@ -31,29 +41,40 @@ import org.openecomp.sdcrests.vsp.rest.mapping.MapProcessEntityToProcessEntityDt import org.openecomp.sdcrests.vsp.rest.mapping.MapProcessRequestDtoToProcessEntity; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; - -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; +import javax.inject.Named; +import javax.ws.rs.core.Response; import java.io.File; import java.io.InputStream; import java.util.Collection; -import javax.inject.Named; -import javax.ws.rs.core.Response; +import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID; @Named @Service("componentProcesses") @Scope(value = "prototype") public class ComponentProcessesImpl implements ComponentProcesses { - @Autowired - private VendorSoftwareProductManager vendorSoftwareProductManager; + + private ProcessManager processManager = ProcessManagerFactory.getInstance().createInterface(); + private ComponentManager componentManager = + ComponentManagerFactory.getInstance().createInterface(); + private static final Logger logger = + LoggerFactory.getLogger(ComponentProcessesImpl.class); @Override - public Response list(String vspId, String componentId, String version, String user) { - Collection<ProcessEntity> processes = vendorSoftwareProductManager - .listProcesses(vspId, Version.valueOf(version), componentId, user); + public Response list(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.List_Component_Processes.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + validateComponentExistence(vspId, vspVersion, componentId, user); + Collection<ProcessEntity> processes; + if (componentId.equals(VendorSoftwareProductConstants.GENERAL_COMPONENT_ID)) { + processes = processManager.listProcesses(vspId, vspVersion, null, user); + } else { + processes = processManager.listProcesses(vspId, vspVersion, componentId, user); + } + MapProcessEntityToProcessEntityDto mapper = new MapProcessEntityToProcessEntityDto(); GenericCollectionWrapper<ProcessEntityDto> results = new GenericCollectionWrapper<>(); @@ -65,58 +86,81 @@ public class ComponentProcessesImpl implements ComponentProcesses { } @Override - public Response deleteList(String vspId, String componentId, String user) { - vendorSoftwareProductManager.deleteProcesses(vspId, componentId, user); + public Response deleteList(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_List_Component_Processes.toString()); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + validateComponentExistence(vspId, version, componentId, user); + processManager.deleteProcesses(vspId, version, componentId, user); + return Response.ok().build(); } @Override - public Response create(ProcessRequestDto request, String vspId, String componentId, String user) { + public Response create(ProcessRequestDto request, String vspId, String versionId, + String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_Component_Processes.toString()); ProcessEntity process = new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class); process.setVspId(vspId); - process.setComponentId(componentId); + process.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); + if (!componentId.equals(VendorSoftwareProductConstants.GENERAL_COMPONENT_ID)) { + process.setComponentId(componentId); + } + + validateComponentExistence(vspId, process.getVersion(), componentId, user); + ProcessEntity createdProcess = processManager.createProcess(process, user); - ProcessEntity createdProcess = vendorSoftwareProductManager.createProcess(process, user); return Response .ok(createdProcess != null ? new StringWrapperResponse(createdProcess.getId()) : null) .build(); } @Override - public Response get(String vspId, String componentId, String processId, String version, + public Response get(String vspId, String versionId, String componentId, String processId, String user) { - ProcessEntity process = vendorSoftwareProductManager - .getProcess(vspId, Version.valueOf(version), componentId, processId, user); + MdcUtil.initMdc(LoggerServiceName.Get_Component_Processes.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + validateComponentExistence(vspId, vspVersion, componentId, user); + ProcessEntity process = + processManager.getProcess(vspId, vspVersion, componentId, processId, user); ProcessEntityDto result = new MapProcessEntityToProcessEntityDto().applyMapping(process, ProcessEntityDto.class); return Response.ok(result).build(); } @Override - public Response delete(String vspId, String componentId, String processId, String user) { - vendorSoftwareProductManager.deleteProcess(vspId, componentId, processId, user); + public Response delete(String vspId, String versionId, String componentId, String processId, + String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_Component_Processes.toString()); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + validateComponentExistence(vspId, version, componentId, user); + processManager.deleteProcess(vspId, version, componentId, processId, user); return Response.ok().build(); } @Override - public Response update(ProcessRequestDto request, String vspId, String componentId, + public Response update(ProcessRequestDto request, String vspId, String versionId, + String componentId, String processId, String user) { - ProcessEntity processEntity = + MdcUtil.initMdc(LoggerServiceName.Update_Component_Processes.toString()); + ProcessEntity process = new MapProcessRequestDtoToProcessEntity().applyMapping(request, ProcessEntity.class); - processEntity.setVspId(vspId); - processEntity.setComponentId(componentId); - processEntity.setId(processId); - - vendorSoftwareProductManager.updateProcess(processEntity, user); + process.setVspId(vspId); + process.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); + process.setComponentId(componentId); + process.setId(processId); + validateComponentExistence(vspId, process.getVersion(), componentId, user); + processManager.updateProcess(process, user); return Response.ok().build(); } @Override - public Response getUploadedFile(String vspId, String componentId, String processId, - String version, String user) { - File file = vendorSoftwareProductManager - .getProcessArtifact(vspId, Version.valueOf(version), componentId, processId, user); + public Response getUploadedFile(String vspId, String versionId, String componentId, + String processId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Uploaded_File_Component_Processes.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + validateComponentExistence(vspId, vspVersion, componentId, user); + File file = processManager.getProcessArtifact(vspId, vspVersion, componentId, processId, user); Response.ResponseBuilder response = Response.ok(file); if (file == null) { @@ -127,18 +171,36 @@ public class ComponentProcessesImpl implements ComponentProcesses { } @Override - public Response deleteUploadedFile(String vspId, String componentId, String processId, + public Response deleteUploadedFile(String vspId, String versionId, String componentId, + String processId, String user) { - vendorSoftwareProductManager.deleteProcessArtifact(vspId, componentId, processId, user); + MdcUtil.initMdc(LoggerServiceName.Delete_Uploaded_File_Component_Processes.toString()); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + validateComponentExistence(vspId, version, componentId, user); + processManager.deleteProcessArtifact(vspId, version, componentId, processId, user); return Response.ok().build(); } @Override - public Response uploadFile(Attachment attachment, String vspId, String componentId, + public Response uploadFile(Attachment attachment, String vspId, String versionId, + String componentId, String processId, String user) { - vendorSoftwareProductManager.uploadProcessArtifact(attachment.getObject(InputStream.class), - attachment.getContentDisposition().getParameter("filename"), vspId, componentId, processId, - user); + MdcUtil.initMdc(LoggerServiceName.Upload_File_Component_Processes.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_PROCESS_ARTIFACT + vspId); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + validateComponentExistence(vspId, version, componentId, user); + processManager.uploadProcessArtifact(attachment.getObject(InputStream.class), + attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, + processId, user); return Response.ok().build(); } + + + private void validateComponentExistence(String vspId, Version version, String componentId, + String user) { + if (GENERAL_COMPONENT_ID.equals(componentId)) { + return; + } + componentManager.validateComponentExistence(vspId, version, componentId, user); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentUploadsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentUploadsImpl.java index 3cd384d7e7..7a2a1578b6 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentUploadsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentUploadsImpl.java @@ -21,63 +21,113 @@ package org.openecomp.sdcrests.vsp.rest.services; import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.core.enrichment.types.ArtifactType; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage; +import org.openecomp.sdc.logging.messages.AuditMessages; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.MibManager; +import org.openecomp.sdc.vendorsoftwareproduct.MibManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MibUploadStatus; +import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; import org.openecomp.sdcrests.vendorsoftwareproducts.types.MibUploadStatusDto; import org.openecomp.sdcrests.vsp.rest.ComponentUploads; import org.openecomp.sdcrests.vsp.rest.mapping.MapMibUploadStatusToDto; - -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import java.io.InputStream; import javax.inject.Named; import javax.ws.rs.core.Response; +import java.io.InputStream; @Named @Service("componentUploads") @Scope(value = "prototype") @Validated public class ComponentUploadsImpl implements ComponentUploads { - @Autowired - private VendorSoftwareProductManager vendorSoftwareProductManager; + private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage(); + private MibManager mibManager = MibManagerFactory.getInstance().createInterface(); + private ComponentManager componentManager = + ComponentManagerFactory.getInstance().createInterface(); + private static final Logger logger = + LoggerFactory.getLogger(ComponentUploadsImpl.class); @Override - public Response uploadTrapMibFile(Attachment attachment, String vspId, String componentId, + public Response uploadTrapMibFile(Attachment attachment, String vspId, String versionId, String componentId, String user) { - vendorSoftwareProductManager.uploadComponentMib(attachment.getObject(InputStream.class), - attachment.getContentDisposition().getParameter("filename"), vspId, componentId, true, - user); + mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); + MdcUtil.initMdc(LoggerServiceName.Upload_MIB_File.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_ARTIFACT_MIB_TRAP + vspId); + + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, version, componentId, user); + mibManager.upload(attachment.getObject(InputStream.class), + attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, + ArtifactType.SNMP_TRAP, user); + + mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); return Response.ok().build(); } @Override - public Response deleteTrapMibFile(String vspId, String componentId, String user) { - vendorSoftwareProductManager.deleteComponentMib(vspId, componentId, true, user); + public Response deleteTrapMibFile(String vspId, String versionId, String componentId, String user) { + mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); + MdcUtil.initMdc(LoggerServiceName.Delete_MIB_File.toString()); + + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, version, componentId, user); + mibManager.delete(vspId, version, componentId, ArtifactType.SNMP_TRAP, user); + + mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); return Response.ok().build(); } @Override - public Response uploadPollMibFile(Attachment attachment, String vspId, String componentId, + public Response uploadPollMibFile(Attachment attachment, String vspId, String versionId, String componentId, String user) { - vendorSoftwareProductManager.uploadComponentMib(attachment.getObject(InputStream.class), - attachment.getContentDisposition().getParameter("filename"), vspId, componentId, false, - user); + + mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_ARTIFACT_MIB_POLL + vspId); + MdcUtil.initMdc(LoggerServiceName.Upload_MIB_File.toString()); + + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, version, componentId, user); + mibManager.upload(attachment.getObject(InputStream.class), + attachment.getContentDisposition().getParameter("filename"), vspId, version, componentId, + ArtifactType.SNMP_POLL, user); + + mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); return Response.ok().build(); } @Override - public Response deletePollMibFile(String vspId, String componentId, String user) { - vendorSoftwareProductManager.deleteComponentMib(vspId, componentId, false, user); + public Response deletePollMibFile(String vspId, String versionId, String componentId, String + user) { + mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId + "," + componentId); + MdcUtil.initMdc(LoggerServiceName.Delete_MIB_File.toString()); + + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, version, componentId, user); + mibManager.delete(vspId, version, componentId, ArtifactType.SNMP_POLL, user); + + mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId + "," + componentId); return Response.ok().build(); } @Override - public Response list(String vspId, String componentId, String user) { - MibUploadStatus response = - vendorSoftwareProductManager.listMibFilenames(vspId, componentId, user); + public Response list(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.List_MIB_Files.toString()); + + Version version = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, version, componentId, user); + + MibUploadStatus response = mibManager.listFilenames(vspId, version, componentId, user); MibUploadStatusDto returnEntity = new MapMibUploadStatusToDto().applyMapping(response, MibUploadStatusDto.class); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java index cba9abbdbc..a36534ae4f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ComponentsImpl.java @@ -21,13 +21,17 @@ package org.openecomp.sdcrests.vsp.rest.services; import org.apache.commons.collections4.CollectionUtils; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity; import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; -import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityValidationData; import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ComponentRequestDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; @@ -42,27 +46,26 @@ import org.openecomp.sdcrests.vsp.rest.mapping.MapCompositionEntityValidationDat import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; - -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import java.util.Collection; import javax.inject.Named; import javax.ws.rs.core.Response; - +import java.util.Collection; @Named @Service("components") @Scope(value = "prototype") public class ComponentsImpl implements Components { - @Autowired - private VendorSoftwareProductManager vendorSoftwareProductManager; + private ComponentManager componentManager = + ComponentManagerFactory.getInstance().createInterface(); @Override - public Response list(String vspId, String version, String user) { + public Response list(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.List_Components.toString()); Collection<ComponentEntity> components = - vendorSoftwareProductManager.listComponents(vspId, Version.valueOf(version), user); + componentManager.listComponents(vspId, resolveVspVersion(vspId, versionId, user, + VersionableEntityAction.Read), user); MapComponentEntityToComponentDto mapper = new MapComponentEntityToComponentDto(); GenericCollectionWrapper<ComponentDto> results = new GenericCollectionWrapper<>(); @@ -74,27 +77,33 @@ public class ComponentsImpl implements Components { } @Override - public Response deleteList(String vspId, String user) { - vendorSoftwareProductManager.deleteComponents(vspId, user); + public Response deleteList(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_List_Components.toString()); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.deleteComponents(vspId, version, user); return Response.ok().build(); } @Override - public Response create(ComponentRequestDto request, String vspId, String user) { + public Response create(ComponentRequestDto request, String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_Component.toString()); ComponentEntity component = new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class); component.setVspId(vspId); - ComponentEntity createdComponent = - vendorSoftwareProductManager.createComponent(component, user); + component.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); + + ComponentEntity createdComponent = componentManager.createComponent(component, user); return Response .ok(createdComponent != null ? new StringWrapperResponse(createdComponent.getId()) : null) .build(); } @Override - public Response get(String vspId, String componentId, String version, String user) { - CompositionEntityResponse<ComponentData> response = vendorSoftwareProductManager - .getComponent(vspId, Version.valueOf(version), componentId, user); + public Response get(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Component.toString()); + CompositionEntityResponse<ComponentData> response = componentManager + .getComponent(vspId, resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), + componentId, user); CompositionEntityResponseDto<ComponentDto> responseDto = new CompositionEntityResponseDto<>(); new MapCompositionEntityResponseToDto<>(new MapComponentDataToComponentDto(), @@ -103,32 +112,38 @@ public class ComponentsImpl implements Components { } @Override - public Response delete(String vspId, String componentId, String user) { - vendorSoftwareProductManager.deleteComponent(vspId, componentId, user); + public Response delete(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_Component.toString()); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.deleteComponent(vspId, version, componentId, user); return Response.ok().build(); } @Override - public Response update(ComponentRequestDto request, String vspId, String componentId, + public Response update(ComponentRequestDto request, String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Update_Component.toString()); ComponentEntity componentEntity = new MapComponentRequestDtoToComponentEntity().applyMapping(request, ComponentEntity.class); componentEntity.setVspId(vspId); + componentEntity.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); componentEntity.setId(componentId); CompositionEntityValidationData validationData = - vendorSoftwareProductManager.updateComponent(componentEntity, user); + componentManager.updateComponent(componentEntity, user); return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto() - .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : - Response.ok().build(); + new MapCompositionEntityValidationDataToDto().applyMapping(validationData, + CompositionEntityValidationDataDto.class)).build() : Response.ok().build(); } @Override - public Response getQuestionnaire(String vspId, String componentId, String version, String user) { - QuestionnaireResponse questionnaireResponse = vendorSoftwareProductManager - .getComponentQuestionnaire(vspId, Version.valueOf(version), componentId, user); + public Response getQuestionnaire(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Questionnaire_Component.toString()); + QuestionnaireResponse questionnaireResponse = componentManager + .getQuestionnaire(vspId, + resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), componentId, + user); QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); @@ -136,10 +151,11 @@ public class ComponentsImpl implements Components { } @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String componentId, + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String componentId, String user) { - vendorSoftwareProductManager - .updateComponentQuestionnaire(vspId, componentId, questionnaireData, user); + MdcUtil.initMdc(LoggerServiceName.Update_Questionnaire_Component.toString()); + Version version = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.updateQuestionnaire(vspId, version, componentId, questionnaireData, user); return Response.ok().build(); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java index afc25ab4b0..471138f23c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NetworksImpl.java @@ -21,12 +21,15 @@ package org.openecomp.sdcrests.vsp.rest.services; import org.apache.commons.collections4.CollectionUtils; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.NetworkManager; +import org.openecomp.sdc.vendorsoftwareproduct.NetworkManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity; import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; -import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityValidationData; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network; -import org.openecomp.sdc.versioning.dao.types.Version; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NetworkDto; @@ -39,26 +42,27 @@ import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkRequestDtoToNetworkEnti import org.openecomp.sdcrests.vsp.rest.mapping.MapNetworkToNetworkDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import java.util.Collection; import javax.inject.Named; import javax.ws.rs.core.Response; - +import java.util.Collection; @Named @Service("networks") @Scope(value = "prototype") public class NetworksImpl implements Networks { - @Autowired - private VendorSoftwareProductManager vendorSoftwareProductManager; + + private NetworkManager networkManager = + NetworkManagerFactory.getInstance().createInterface(); @Override - public Response list(String vspId, String version, String user) { + public Response list(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.List_Network.toString()); Collection<NetworkEntity> networks = - vendorSoftwareProductManager.listNetworks(vspId, Version.valueOf(version), user); + networkManager.listNetworks(vspId, + resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), user); MapNetworkEntityToNetworkDto mapper = new MapNetworkEntityToNetworkDto(); GenericCollectionWrapper<NetworkDto> results = new GenericCollectionWrapper<>(); @@ -70,20 +74,25 @@ public class NetworksImpl implements Networks { } @Override - public Response create(NetworkRequestDto request, String vspId, String user) { + public Response create(NetworkRequestDto request, String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_Network.toString()); NetworkEntity network = new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class); network.setVspId(vspId); - NetworkEntity createdNetwork = vendorSoftwareProductManager.createNetwork(network, user); + network.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); + NetworkEntity createdNetwork = networkManager.createNetwork(network, user); return Response .ok(createdNetwork != null ? new StringWrapperResponse(createdNetwork.getId()) : null) .build(); } @Override - public Response get(String vspId, String networkId, String version, String user) { + public Response get(String vspId, String versionId, String networkId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Network.toString()); CompositionEntityResponse<Network> response = - vendorSoftwareProductManager.getNetwork(vspId, Version.valueOf(version), networkId, user); + networkManager.getNetwork(vspId, + resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), networkId, + user); CompositionEntityResponseDto<NetworkDto> responseDto = new CompositionEntityResponseDto<>(); new MapCompositionEntityResponseToDto<>(new MapNetworkToNetworkDto(), NetworkDto.class) @@ -92,24 +101,29 @@ public class NetworksImpl implements Networks { } @Override - public Response delete(String vspId, String networkId, String user) { - vendorSoftwareProductManager.deleteNetwork(vspId, networkId, user); + public Response delete(String vspId, String versionId, String networkId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_Network.toString()); + networkManager + .deleteNetwork(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction.Write), + networkId, user); return Response.ok().build(); } @Override - public Response update(NetworkRequestDto request, String vspId, String networkId, String user) { + public Response update(NetworkRequestDto request, String vspId, String versionId, String networkId, String user) { + MdcUtil.initMdc(LoggerServiceName.Update_Network.toString()); NetworkEntity networkEntity = new MapNetworkRequestDtoToNetworkEntity().applyMapping(request, NetworkEntity.class); networkEntity.setVspId(vspId); + networkEntity.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); networkEntity.setId(networkId); CompositionEntityValidationData validationData = - vendorSoftwareProductManager.updateNetwork(networkEntity, user); + networkManager.updateNetwork(networkEntity, user); return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto() - .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : + new MapCompositionEntityValidationDataToDto() + .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : Response.ok().build(); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java index ce601ec999..922700671c 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/NicsImpl.java @@ -21,14 +21,19 @@ package org.openecomp.sdcrests.vsp.rest.services; import org.apache.commons.collections4.CollectionUtils; -import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager; +import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.NicManager; +import org.openecomp.sdc.vendorsoftwareproduct.NicManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse; -import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityValidationData; import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic; import org.openecomp.sdc.versioning.dao.types.Version; - +import org.openecomp.sdc.versioning.types.VersionableEntityAction; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityResponseDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.CompositionEntityValidationDataDto; import org.openecomp.sdcrests.vendorsoftwareproducts.types.NicDto; @@ -43,27 +48,27 @@ import org.openecomp.sdcrests.vsp.rest.mapping.MapNicToNicDto; import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; import org.openecomp.sdcrests.wrappers.StringWrapperResponse; - -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; -import java.util.Collection; import javax.inject.Named; import javax.ws.rs.core.Response; - +import java.util.Collection; @Named @Service("nics") @Scope(value = "prototype") public class NicsImpl implements Nics { - @Autowired - private VendorSoftwareProductManager vendorSoftwareProductManager; + private NicManager nicManager = NicManagerFactory.getInstance().createInterface(); + private ComponentManager componentManager = + ComponentManagerFactory.getInstance().createInterface(); @Override - public Response list(String vspId, String componentId, String version, String user) { - Collection<NicEntity> nics = - vendorSoftwareProductManager.listNics(vspId, Version.valueOf(version), componentId, user); + public Response list(String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.List_nics.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + Collection<NicEntity> nics = nicManager.listNics(vspId, vspVersion, componentId, user); MapNicEntityToNicDto mapper = new MapNicEntityToNicDto(); GenericCollectionWrapper<NicDto> results = new GenericCollectionWrapper<>(); @@ -75,20 +80,26 @@ public class NicsImpl implements Nics { } @Override - public Response create(NicRequestDto request, String vspId, String componentId, String user) { + public Response create(NicRequestDto request, String vspId, String versionId, String componentId, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_nic.toString()); NicEntity nic = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class); nic.setVspId(vspId); + nic.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); nic.setComponentId(componentId); + componentManager.validateComponentExistence(vspId, nic.getVersion(), componentId, user); - NicEntity createdNic = vendorSoftwareProductManager.createNic(nic, user); + NicEntity createdNic = nicManager.createNic(nic, user); return Response.ok(createdNic != null ? new StringWrapperResponse(createdNic.getId()) : null) .build(); } @Override - public Response get(String vspId, String componentId, String nicId, String version, String user) { - CompositionEntityResponse<Nic> response = vendorSoftwareProductManager - .getNic(vspId, Version.valueOf(version), componentId, nicId, user); + public Response get(String vspId, String versionId, String componentId, String nicId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_nic.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + CompositionEntityResponse<Nic> response = + nicManager.getNic(vspId, vspVersion, componentId, nicId, user); CompositionEntityResponseDto<NicDto> responseDto = new CompositionEntityResponseDto<>(); new MapCompositionEntityResponseToDto<>(new MapNicToNicDto(), NicDto.class) @@ -97,33 +108,42 @@ public class NicsImpl implements Nics { } @Override - public Response delete(String vspId, String componentId, String nicId, String user) { - vendorSoftwareProductManager.deleteNic(vspId, componentId, nicId, user); + public Response delete(String vspId, String versionId, String componentId, String nicId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_nic.toString()); + Version vspVersion = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + nicManager.deleteNic(vspId, vspVersion, componentId, nicId, user); return Response.ok().build(); } @Override - public Response update(NicRequestDto request, String vspId, String componentId, String nicId, + public Response update(NicRequestDto request, String vspId, String versionId, String componentId, String nicId, String user) { + MdcUtil.initMdc(LoggerServiceName.Update_nic.toString()); NicEntity nicEntity = new MapNicRequestDtoToNicEntity().applyMapping(request, NicEntity.class); nicEntity.setVspId(vspId); + nicEntity.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); nicEntity.setComponentId(componentId); nicEntity.setId(nicId); + componentManager.validateComponentExistence(vspId, nicEntity.getVersion(), componentId, user); CompositionEntityValidationData validationData = - vendorSoftwareProductManager.updateNic(nicEntity, user); + nicManager.updateNic(nicEntity, user); return validationData != null && CollectionUtils.isNotEmpty(validationData.getErrors()) ? Response.status(Response.Status.EXPECTATION_FAILED).entity( - new MapCompositionEntityValidationDataToDto() - .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : + new MapCompositionEntityValidationDataToDto() + .applyMapping(validationData, CompositionEntityValidationDataDto.class)).build() : Response.ok().build(); } @Override - public Response getQuestionnaire(String vspId, String componentId, String nicId, String version, + public Response getQuestionnaire(String vspId, String versionId, String componentId, String nicId, String user) { - QuestionnaireResponse questionnaireResponse = vendorSoftwareProductManager - .getNicQuestionnaire(vspId, Version.valueOf(version), componentId, nicId, user); + MdcUtil.initMdc(LoggerServiceName.Get_Questionnaire_nic.toString()); + Version vspVersion = resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + QuestionnaireResponse questionnaireResponse = + nicManager.getNicQuestionnaire(vspId, vspVersion, componentId, nicId, user); QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); @@ -131,10 +151,13 @@ public class NicsImpl implements Nics { } @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String componentId, + public Response updateQuestionnaire(String questionnaireData, String vspId, String versionId, String componentId, String nicId, String user) { - vendorSoftwareProductManager - .updateNicQuestionnaire(vspId, componentId, nicId, questionnaireData, user); + MdcUtil.initMdc(LoggerServiceName.Update_Questionnaire_nic.toString()); + Version vspVersion = resolveVspVersion(vspId, null, user, VersionableEntityAction.Write); + componentManager.validateComponentExistence(vspId, vspVersion, componentId, user); + nicManager + .updateNicQuestionnaire(vspId, vspVersion, componentId, nicId, questionnaireData, user); return Response.ok().build(); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java new file mode 100644 index 0000000000..d5eb961285 --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java @@ -0,0 +1,134 @@ +package org.openecomp.sdcrests.vsp.rest.services; + +import org.apache.commons.beanutils.BeanUtils; +import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder; +import org.openecomp.sdc.common.errors.Messages; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.messages.AuditMessages; +import org.openecomp.sdc.logging.types.LoggerServiceName; +import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager; +import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory; +import org.openecomp.sdc.vendorsoftwareproduct.types.FileDataStructureDto; +import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.OrchestrationTemplateActionResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto; +import org.openecomp.sdcrests.vsp.rest.OrchestrationTemplateCandidate; +import org.openecomp.sdcrests.vsp.rest.mapping.MapUploadFileResponseToUploadFileResponseDto; +import org.openecomp.sdcrests.vsp.rest.mapping.MapValidationResponseToDto; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +import javax.inject.Named; +import javax.ws.rs.core.Response; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; +import java.util.Optional; + +@Named +@Service("orchestrationTemplateCandidate") +@Scope(value = "prototype") +public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplateCandidate { + + private OrchestrationTemplateCandidateManager candidateManager = + OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface(); + private static final Logger logger = + LoggerFactory.getLogger(OrchestrationTemplateCandidateImpl.class); + + @Override + public Response upload(String vspId, String versionId, InputStream heatFileToUpload, + String user) { + MdcUtil.initMdc(LoggerServiceName.Upload_File.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_HEAT + vspId); + + UploadFileResponse uploadFileResponse = candidateManager + .upload(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction + .Write), heatFileToUpload, user); + UploadFileResponseDto uploadFileResponseDto = new MapUploadFileResponseToUploadFileResponseDto() + .applyMapping(uploadFileResponse, UploadFileResponseDto.class); + + return Response.ok(uploadFileResponseDto).build(); + } + + @Override + public Response get(String vspId, String versionId, String user) throws IOException { + Optional<byte[]> zipFile = + candidateManager + .get(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction.Read), user); + + if (!zipFile.isPresent()) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + Response.ResponseBuilder response = Response.ok(zipFile.get()); + response.header("Content-Disposition", "attachment; filename=HeatCandidate.zip"); + return response.build(); + } + + @Override + public Response process(String vspId, String versionId, String user) + throws InvocationTargetException, IllegalAccessException { + + OrchestrationTemplateActionResponse response = + candidateManager + .process(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction.Write), + user); + OrchestrationTemplateActionResponseDto responseDto = + new OrchestrationTemplateActionResponseDto(); + BeanUtils.copyProperties(responseDto, response); + return Response.ok(responseDto).build(); + } + + @Override + public Response updateFilesDataStructure( + String vspId, String versionId, FileDataStructureDto fileDataStructureDto, String user) + throws Exception { + + FilesDataStructure fileDataStructure = new FilesDataStructure(); + try { + BeanUtils.copyProperties(fileDataStructure, fileDataStructureDto); + } catch (IllegalAccessException | InvocationTargetException exception) { + String errorWithParameters = ErrorMessagesFormatBuilder + .getErrorWithParameters(Messages.MAPPING_OBJECTS_FAILURE.getErrorMessage(), + fileDataStructureDto.toString(), fileDataStructure.toString()); + throw new Exception(errorWithParameters, exception); + } + ValidationResponse response = candidateManager + .updateFilesDataStructure(vspId, + resolveVspVersion(vspId, null, user, VersionableEntityAction + .Write), user, fileDataStructure); + + if (!response.isValid()) { + return Response.status(Response.Status.EXPECTATION_FAILED).entity( + new MapValidationResponseToDto() + .applyMapping(response, ValidationResponseDto.class)).build(); + } + return Response.ok(fileDataStructureDto).build(); + } + + @Override + public Response getFilesDataStructure(String vspId, String versionId, String user) + throws Exception { + Optional<FilesDataStructure> filesDataStructure = candidateManager + .getFilesDataStructure(vspId, resolveVspVersion(vspId, null, user, VersionableEntityAction + .Read), user); + FileDataStructureDto fileDataStructureDto = new FileDataStructureDto(); + if (filesDataStructure.isPresent()) { + try { + BeanUtils.copyProperties(fileDataStructureDto, filesDataStructure.get()); + } catch (IllegalAccessException | InvocationTargetException exception) { + String errorWithParameters = ErrorMessagesFormatBuilder + .getErrorWithParameters(Messages.MAPPING_OBJECTS_FAILURE.getErrorMessage(), + filesDataStructure.toString(), fileDataStructureDto.toString()); + throw new Exception(errorWithParameters, exception); + } + } + return Response.ok(fileDataStructureDto).build(); + } +} diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java index 004d84591a..a175908cd1 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/ProcessesImpl.java @@ -20,9 +20,12 @@ package org.openecomp.sdcrests.vsp.rest.services; -import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID; - import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.messages.AuditMessages; +import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdcrests.vendorsoftwareproducts.types.ProcessRequestDto; import org.openecomp.sdcrests.vsp.rest.ComponentProcesses; import org.openecomp.sdcrests.vsp.rest.Processes; @@ -33,6 +36,8 @@ import org.springframework.stereotype.Service; import javax.inject.Named; import javax.ws.rs.core.Response; +import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID; + @Named @Service("processes") @Scope(value = "prototype") @@ -40,50 +45,65 @@ public class ProcessesImpl implements Processes { @Autowired private ComponentProcesses componentProcesses; + private static final Logger logger = + LoggerFactory.getLogger(ProcessesImpl.class); @Override - public Response list(String vspId, String version, String user) { - return componentProcesses.list(vspId, GENERAL_COMPONENT_ID, version, user); + public Response list(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.List_Processes.toString()); + return componentProcesses.list(vspId, versionId, GENERAL_COMPONENT_ID, user); } @Override - public Response deleteList(String vspId, String user) { - return componentProcesses.deleteList(vspId, GENERAL_COMPONENT_ID, user); + public Response deleteList(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_List_Processes.toString()); + return componentProcesses.deleteList(vspId,versionId, GENERAL_COMPONENT_ID, user); } @Override - public Response create(ProcessRequestDto request, String vspId, String user) { - return componentProcesses.create(request, vspId, GENERAL_COMPONENT_ID, user); + public Response create(ProcessRequestDto request, String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_Process.toString()); + return componentProcesses.create(request, vspId, versionId, GENERAL_COMPONENT_ID, user); } @Override - public Response get(String vspId, String processId, String version, String user) { - return componentProcesses.get(vspId, GENERAL_COMPONENT_ID, processId, version, user); + public Response get(String vspId, String versionId, String processId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Processes.toString()); + return componentProcesses.get(vspId, versionId, GENERAL_COMPONENT_ID, processId, user); } @Override - public Response delete(String vspId, String processId, String user) { - return componentProcesses.delete(vspId, GENERAL_COMPONENT_ID, processId, user); + public Response delete(String vspId, String versionId, String processId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_Processes.toString()); + return componentProcesses.delete(vspId, versionId, GENERAL_COMPONENT_ID, processId, user); } @Override - public Response update(ProcessRequestDto request, String vspId, String processId, String user) { - return componentProcesses.update(request, vspId, GENERAL_COMPONENT_ID, processId, user); + public Response update(ProcessRequestDto request, String vspId, String versionId, String processId, String user) { + MdcUtil.initMdc(LoggerServiceName.Update_Process.toString()); + return componentProcesses.update(request, vspId, versionId, GENERAL_COMPONENT_ID, processId, user); } @Override - public Response getUploadedFile(String vspId, String processId, String version, String user) { + public Response getUploadedFile(String vspId, String versionId, String processId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Uploaded_File_Processes.toString()); return componentProcesses - .getUploadedFile(vspId, GENERAL_COMPONENT_ID, processId, version, user); + .getUploadedFile(vspId, versionId, GENERAL_COMPONENT_ID, processId, user); } @Override - public Response deleteUploadedFile(String vspId, String processId, String user) { - return componentProcesses.deleteUploadedFile(vspId, GENERAL_COMPONENT_ID, processId, user); + public Response deleteUploadedFile(String vspId, String versionId, String processId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_Uploaded_File_Processes.toString()); + return componentProcesses.deleteUploadedFile(vspId, versionId, GENERAL_COMPONENT_ID, + processId, user); } @Override - public Response uploadFile(Attachment attachment, String vspId, String processId, String user) { - return componentProcesses.uploadFile(attachment, vspId, GENERAL_COMPONENT_ID, processId, user); + public Response uploadFile(Attachment attachment, String vspId, String versionId, String processId, String user) { + MdcUtil.initMdc(LoggerServiceName.Upload_File_Processes.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.UPLOAD_PROCESS_ARTIFACT + vspId); + return componentProcesses.uploadFile(attachment, vspId, versionId, GENERAL_COMPONENT_ID, + processId, + user); } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java index 1c13f172f1..9f8f3d366f 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/VendorSoftwareProductsImpl.java @@ -20,126 +20,171 @@ package org.openecomp.sdcrests.vsp.rest.services; +import org.openecomp.sdc.activityLog.ActivityLogManager; +import org.openecomp.sdc.activityLog.ActivityLogManagerFactory; +import org.openecomp.sdc.logging.api.Logger; +import org.openecomp.sdc.logging.api.LoggerFactory; +import org.openecomp.sdc.logging.context.MdcUtil; +import org.openecomp.sdc.logging.messages.AuditMessages; +import org.openecomp.sdc.logging.types.LoggerConstants; +import org.openecomp.sdc.logging.types.LoggerServiceName; import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; +import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; -import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo; import org.openecomp.sdc.versioning.dao.types.Version; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.PackageInfoDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.QuestionnaireResponseDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.UploadFileResponseDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.ValidationResponseDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.VersionSoftwareProductActionRequestDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspCreationDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; -import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; +import org.openecomp.sdc.versioning.types.VersionInfo; +import org.openecomp.sdc.versioning.types.VersionableEntityAction; +import org.openecomp.sdcrests.vendorsoftwareproducts.types.*; import org.openecomp.sdcrests.vsp.rest.VendorSoftwareProducts; -import org.openecomp.sdcrests.vsp.rest.mapping.MapPackageInfoToPackageInfoDto; -import org.openecomp.sdcrests.vsp.rest.mapping.MapQuestionnaireResponseToQuestionnaireResponseDto; -import org.openecomp.sdcrests.vsp.rest.mapping.MapUploadFileResponseToUploadFileResponseDto; -import org.openecomp.sdcrests.vsp.rest.mapping.MapValidationResponseToDto; -import org.openecomp.sdcrests.vsp.rest.mapping.MapVersionedVendorSoftwareProductInfoToVspDetailsDto; -import org.openecomp.sdcrests.vsp.rest.mapping.MapVspDescriptionDtoToVspDetails; -import org.openecomp.sdcrests.vsp.rest.mapping.MspVspDetailsToVspCreationDto; +import org.openecomp.sdcrests.vsp.rest.mapping.*; import org.openecomp.sdcrests.wrappers.GenericCollectionWrapper; - -import org.springframework.beans.factory.annotation.Autowired; +import org.openecomp.sdcrests.wrappers.StringWrapperResponse; +import org.slf4j.MDC; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; +import javax.inject.Named; +import javax.ws.rs.core.Response; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.util.List; -import javax.inject.Named; -import javax.ws.rs.core.Response; + @Named @Service("vendorSoftwareProducts") @Scope(value = "prototype") public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { - @Autowired - private VendorSoftwareProductManager vendorSoftwareProductManager; + private VendorSoftwareProductManager vendorSoftwareProductManager = + VspManagerFactory.getInstance().createInterface(); - @Override - public Response createNewVsp(VspDescriptionDto vspDescriptionDto, String user) { - VspDetails vspDetails = - new MapVspDescriptionDtoToVspDetails().applyMapping(vspDescriptionDto, VspDetails.class); + private static final Logger logger = + LoggerFactory.getLogger(VendorSoftwareProductsImpl.class); - vspDetails = vendorSoftwareProductManager.createNewVsp(vspDetails, user); + private ActivityLogManager activityLogManager = + ActivityLogManagerFactory.getInstance().createInterface(); - MspVspDetailsToVspCreationDto mapping = new MspVspDetailsToVspCreationDto(); - VspCreationDto vspCreationDto = mapping.applyMapping(vspDetails, VspCreationDto.class); + @Override + public Response createVsp(VspDescriptionDto vspDescriptionDto, String user) { + MdcUtil.initMdc(LoggerServiceName.Create_VSP.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_VSP + vspDescriptionDto.getName()); - return Response.ok(vspCreationDto).build(); - } + VspDetails vspDetails = + new MapVspDescriptionDtoToVspDetails().applyMapping(vspDescriptionDto, VspDetails.class); - @Override - public Response getVspList(String versionFilter, String user) { - List<VersionedVendorSoftwareProductInfo> vspList = - vendorSoftwareProductManager.getVspList(versionFilter, user); - - GenericCollectionWrapper<VspDetailsDto> results = new GenericCollectionWrapper<>(); - if (!vspList.isEmpty()) { - MapVersionedVendorSoftwareProductInfoToVspDetailsDto mapper = - new MapVersionedVendorSoftwareProductInfoToVspDetailsDto(); - for (VersionedVendorSoftwareProductInfo versionedVsp : vspList) { - results.add(mapper.applyMapping(versionedVsp, VspDetailsDto.class)); - } + vspDetails = vendorSoftwareProductManager.createVsp(vspDetails, user); + + MspVspDetailsToVspCreationDto mapping = new MspVspDetailsToVspCreationDto(); + VspCreationDto vspCreationDto = mapping.applyMapping(vspDetails, VspCreationDto.class); + + return Response.ok(vspCreationDto).build(); } - return Response.ok(results).build(); - } + @Override + public Response listVsps(String versionFilter, String user) { + MdcUtil.initMdc(LoggerServiceName.List_VSP.toString()); + List<VersionedVendorSoftwareProductInfo> vspList = + vendorSoftwareProductManager.listVsps(versionFilter, user); + + GenericCollectionWrapper<VspDetailsDto> results = new GenericCollectionWrapper<>(); + if (!vspList.isEmpty()) { + MapVersionedVendorSoftwareProductInfoToVspDetailsDto mapper = + new MapVersionedVendorSoftwareProductInfoToVspDetailsDto(); + for (VersionedVendorSoftwareProductInfo versionedVsp : vspList) { + results.add(mapper.applyMapping(versionedVsp, VspDetailsDto.class)); + } + } + + return Response.ok(results).build(); + } @Override - public Response getVspDetails(String vspId, String version, String user) { - VersionedVendorSoftwareProductInfo vspDetails = - vendorSoftwareProductManager.getVspDetails(vspId, Version.valueOf(version), user); + public Response getVsp(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_VSP.toString()); + + + VspDetails vspDetails = + vendorSoftwareProductManager + .getVsp(vspId, resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), + user); + + VersionInfo versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user); + + // + if(vspDetails.getOldVersion()!=null && !"".equals(vspDetails.getOldVersion())) { + if (Version.valueOf(versionId).equals(versionInfo.getActiveVersion())) { + try { + Version healedVersion = vendorSoftwareProductManager.callAutoHeal(vspId, versionInfo, + vspDetails , user); + vspDetails = + vendorSoftwareProductManager + .getVsp(vspId, resolveVspVersion(vspId, healedVersion.toString(), user, + VersionableEntityAction.Read),user); + versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user); + } catch (Exception e) { + //to do + } + } + } - VspDetailsDto vspDetailsDto = vspDetails == null ? null + VspDetailsDto vspDetailsDto = vspDetails == null + ? null : new MapVersionedVendorSoftwareProductInfoToVspDetailsDto() - .applyMapping(vspDetails, VspDetailsDto.class); + .applyMapping(new VersionedVendorSoftwareProductInfo(vspDetails, versionInfo), + VspDetailsDto.class); - return Response.ok(vspDetailsDto).build(); - } + return Response.ok(vspDetailsDto).build(); + } @Override - public Response updateVsp(String vspId, VspDescriptionDto vspDescriptionDto, String user) { + public Response updateVsp(String vspId, String versionId, VspDescriptionDto vspDescriptionDto, + String user) { + MdcUtil.initMdc(LoggerServiceName.Update_VSP.toString()); VspDetails vspDetails = new MapVspDescriptionDtoToVspDetails().applyMapping(vspDescriptionDto, VspDetails.class); vspDetails.setId(vspId); + vspDetails.setVersion(resolveVspVersion(vspId, null, user, VersionableEntityAction.Write)); - vendorSoftwareProductManager.updateVsp(vspDetails, user); + vendorSoftwareProductManager.updateVsp(vspDetails, user); - return Response.ok().build(); - } + return Response.ok().build(); + } - @Override - public Response deleteVsp(String vspId, String user) { - vendorSoftwareProductManager.deleteVsp(vspId, user); + @Override + public Response deleteVsp(String vspId, String user) { + MdcUtil.initMdc(LoggerServiceName.Delete_VSP.toString()); + vendorSoftwareProductManager.deleteVsp(vspId, user); - return Response.ok().build(); - } + return Response.ok().build(); + } + + @Override + public Response actOnVendorSoftwareProduct(String vspId, String versionId, + VersionSoftwareProductActionRequestDto request, + String user) throws IOException { - @Override - public Response actOnVendorSoftwareProduct(String vspId, - VersionSoftwareProductActionRequestDto request, - String user) throws IOException { switch (request.getAction()) { case Checkout: + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Checkout_VSP.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CHECK_OUT_VSP + vspId); vendorSoftwareProductManager.checkout(vspId, user); break; case Undo_Checkout: + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Undo_Checkout_VSP.toString()); vendorSoftwareProductManager.undoCheckout(vspId, user); break; case Checkin: + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Checkin_VSP.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CHECK_IN_VSP + vspId); vendorSoftwareProductManager.checkin(vspId, user); break; case Submit: + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Submit_VSP.toString()); + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.SUBMIT_VSP + vspId); ValidationResponse validationResponse = vendorSoftwareProductManager.submit(vspId, user); if (!validationResponse.isValid()) { return Response.status(Response.Status.EXPECTATION_FAILED).entity( @@ -148,8 +193,12 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { } break; case Create_Package: - PackageInfo packageInfo = vendorSoftwareProductManager.createPackage(vspId, user); - return Response.ok(packageInfo == null ? null + MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Create_Package.toString()); + + PackageInfo packageInfo = vendorSoftwareProductManager.createPackage(vspId, + resolveVspVersion(vspId, null, user, VersionableEntityAction.Read), user); + return Response.ok(packageInfo == null + ? null : new MapPackageInfoToPackageInfoDto().applyMapping(packageInfo, PackageInfoDto.class)) .build(); default: @@ -158,71 +207,119 @@ public class VendorSoftwareProductsImpl implements VendorSoftwareProducts { return Response.ok().build(); } - @Override - public Response uploadFile(String uploadVspId, InputStream heatFileToUpload, String user) { - UploadFileResponse uploadFileResponse = - vendorSoftwareProductManager.uploadFile(uploadVspId, heatFileToUpload, user); - - UploadFileResponseDto uploadFileResponseDto = new MapUploadFileResponseToUploadFileResponseDto() - .applyMapping(uploadFileResponse, UploadFileResponseDto.class); + @Override + public Response getValidationVsp(String user) + throws Exception { + String validationVspId = vendorSoftwareProductManager.fetchValidationVsp(user); + StringWrapperResponse response = new StringWrapperResponse(validationVspId); + return Response.ok(response).build(); + } - return Response.ok(uploadFileResponseDto).build(); - } - @Override - public Response getLatestHeatPackage(String vspId, String user) { - File zipFile = vendorSoftwareProductManager.getLatestHeatPackage(vspId, user); + @Override + public Response getOrchestrationTemplate(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Uploaded_File.toString()); + byte[] orchestrationTemplateFile = + vendorSoftwareProductManager + .getOrchestrationTemplateFile(vspId, + resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), user); - if (zipFile == null) { - return Response.status(Response.Status.NOT_FOUND).build(); + if (orchestrationTemplateFile == null) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + Response.ResponseBuilder response = Response.ok(orchestrationTemplateFile); + response.header("Content-Disposition", "attachment; filename=LatestHeatPackage.zip"); + return response.build(); } - Response.ResponseBuilder response = Response.ok(zipFile); - response.header("Content-Disposition", "attachment; filename=" + zipFile.getName()); - return response.build(); - } - @Override - public Response listPackages(String category, String subCategory, String user) { - List<PackageInfo> packageInfoList = - vendorSoftwareProductManager.listPackages(category, subCategory); + @Override + public Response listPackages(String category, String subCategory, String user) { + MdcUtil.initMdc(LoggerServiceName.List_Packages.toString()); + List<PackageInfo> packageInfoList = + vendorSoftwareProductManager.listPackages(category, subCategory); - GenericCollectionWrapper<PackageInfoDto> results = new GenericCollectionWrapper<>(); - MapPackageInfoToPackageInfoDto mapper = new MapPackageInfoToPackageInfoDto(); + GenericCollectionWrapper<PackageInfoDto> results = new GenericCollectionWrapper<>(); + MapPackageInfoToPackageInfoDto mapper = new MapPackageInfoToPackageInfoDto(); - if (packageInfoList != null) { - for (PackageInfo packageInfo : packageInfoList) { - results.add(mapper.applyMapping(packageInfo, PackageInfoDto.class)); - } + if (packageInfoList != null) { + for (PackageInfo packageInfo : packageInfoList) { + results.add(mapper.applyMapping(packageInfo, PackageInfoDto.class)); + } + } + return Response.ok(results).build(); } - return Response.ok(results).build(); - } @Override public Response getTranslatedFile(String vspId, String version, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Translated_File.toString()); File zipFile = - vendorSoftwareProductManager.getTranslatedFile(vspId, Version.valueOf(version), user); + vendorSoftwareProductManager.getTranslatedFile(vspId,Version.valueOf(version), user); + + Version versionObj = Version.valueOf(version); + Version resolvedVersion = versionObj == null + ? getVersionInfo(vspId, VersionableEntityAction.Read, user).getLatestFinalVersion() + : versionObj; - Response.ResponseBuilder response = Response.ok(zipFile); - if (zipFile == null) { - return Response.status(Response.Status.NOT_FOUND).build(); + + Response.ResponseBuilder response = Response.ok(zipFile); + if (zipFile == null) { + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.IMPORT_FAIL + vspId); + return Response.status(Response.Status.NOT_FOUND).build(); + } + response.header("Content-Disposition", "attachment; filename=" + zipFile.getName()); + + logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.IMPORT_SUCCESS + vspId); + return response.build(); } - response.header("Content-Disposition", "attachment; filename=" + zipFile.getName()); - return response.build(); - } - @Override - public Response getQuestionnaire(String vspId, String version, String user) { - QuestionnaireResponse questionnaireResponse = - vendorSoftwareProductManager.getVspQuestionnaire(vspId, Version.valueOf(version), user); + @Override + public Response getQuestionnaire(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Questionnaire_VSP.toString()); + QuestionnaireResponse questionnaireResponse = + vendorSoftwareProductManager.getVspQuestionnaire(vspId, + resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), user); + + if (questionnaireResponse.getErrorMessage() != null) { + return Response.status(Response.Status.EXPECTATION_FAILED).entity( + new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class)).build(); + } - QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() - .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); - return Response.ok(result).build(); - } + QuestionnaireResponseDto result = new MapQuestionnaireResponseToQuestionnaireResponseDto() + .applyMapping(questionnaireResponse, QuestionnaireResponseDto.class); + return Response.ok(result).build(); + } @Override - public Response updateQuestionnaire(String questionnaireData, String vspId, String user) { - vendorSoftwareProductManager.updateVspQuestionnaire(vspId, questionnaireData, user); + public Response updateQuestionnaire(String questionnaireData, String vspId, String + versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Update_Questionnaire_VSP.toString()); + vendorSoftwareProductManager.updateVspQuestionnaire(vspId, + resolveVspVersion(vspId, null, user, VersionableEntityAction.Write), + questionnaireData, user); return Response.ok().build(); } + + @Override + public Response heal(String vspId, String versionId, String user) { + vendorSoftwareProductManager.heal(vspId, Version.valueOf(versionId), user); + + return Response.ok().build(); + } + + @Override + public Response getVspInformationArtifact(String vspId, String versionId, String user) { + MdcUtil.initMdc(LoggerServiceName.Get_Information_Artifact.toString()); + File textInformationArtifact = + vendorSoftwareProductManager.getInformationArtifact(vspId, + resolveVspVersion(vspId, versionId, user, VersionableEntityAction.Read), user); + + Response.ResponseBuilder response = Response.ok(textInformationArtifact); + if (textInformationArtifact == null) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + response + .header("Content-Disposition", "attachment; filename=" + textInformationArtifact.getName()); + return response.build(); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml index 9d7e7fb3f1..f460fc5781 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml @@ -4,6 +4,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> + <artifactId>vendor-software-products-rest-types</artifactId> + <name>vendor-software-products-rest-types</name> + <parent> <groupId>org.openecomp.sdc.onboarding</groupId> <artifactId>vendor-software-products-rest</artifactId> @@ -11,11 +14,6 @@ <relativePath>../</relativePath> </parent> - <artifactId>vendor-software-products-rest-types</artifactId> - <name>vendor-software-products-rest-types</name> - - - <dependencies> <dependency> <groupId>org.openecomp.sdc</groupId> @@ -29,4 +27,4 @@ </dependency> </dependencies> -</project>
\ No newline at end of file +</project> diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml.versionsBackup b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml.versionsBackup new file mode 100644 index 0000000000..7fb5fd711e --- /dev/null +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/pom.xml.versionsBackup @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <artifactId>vendor-software-products-rest-types</artifactId> + <name>vendor-software-products-rest-types</name> + + <parent> + <groupId>org.openecomp.sdc.onboarding</groupId> + <artifactId>vendor-software-products-rest</artifactId> + <version>1.0-SNAPSHOT</version> + <relativePath>../</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-common-rest</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>openecomp-sdc-vendor-software-product-manager</artifactId> + <version>1.0-SNAPSHOT</version> + </dependency> + </dependencies> + +</project>
\ No newline at end of file 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 new file mode 100644 index 0000000000..4e908ed99d --- /dev/null +++ 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 @@ -0,0 +1,35 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + + +import org.hibernate.validator.constraints.NotBlank; + +public class ComponentDependencyModel { + + private String sourceId; + private String targetId; + private String relationType; + + public String getSourceId() { + return sourceId; + } + + public void setSourceId(String sourceId) { + this.sourceId = sourceId; + } + + public String getTargetId() { + return targetId; + } + + public void setTargetId(String targetId) { + this.targetId = targetId; + } + + public String getRelationType() { + return relationType; + } + + public void setRelationType(String relationType) { + this.relationType = 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/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 new file mode 100644 index 0000000000..12fed3e377 --- /dev/null +++ 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 @@ -0,0 +1,18 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + + +import java.util.List; + +public class ComponentDependencyModelRequestDto { + + private List<ComponentDependencyModel> componentDependencyModels; + + public List<ComponentDependencyModel> getComponentDependencyModels() { + return componentDependencyModels; + } + + public void setComponentDependencyModels( + List<ComponentDependencyModel> componentDependencyModels) { + this.componentDependencyModels = 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/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 new file mode 100644 index 0000000000..12bb02cd15 --- /dev/null +++ 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 @@ -0,0 +1,6 @@ +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +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 f626dab072..8d2fd4b48d 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 @@ -24,6 +24,7 @@ public class ComponentRequestDto { private String name; private String displayName; + private String vfcCode; private String description; public String getName() { @@ -50,4 +51,11 @@ public class ComponentRequestDto { this.description = description; } + public String getVfcCode() { + return vfcCode; + } + + public void setVfcCode(String vfcCode) { + this.vfcCode = vfcCode; + } } 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 20e07880c4..696ac45c57 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 @@ -27,6 +27,7 @@ import java.util.Collection; public class CompositionEntityValidationDataDto { private CompositionEntityType entityType; private String entityId; + private String entityName; private Collection<String> errors; private Collection<CompositionEntityValidationDataDto> subEntitiesValidationData; @@ -46,6 +47,14 @@ public class CompositionEntityValidationDataDto { this.entityId = entityId; } + public String getEntityName() { + return entityName; + } + + public void setEntityName(String entityName) { + this.entityName = entityName; + } + public Collection<String> getErrors() { return errors; } 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 new file mode 100644 index 0000000000..e31a8aa23e --- /dev/null +++ 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 @@ -0,0 +1,28 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +/** + * Created by Talio on 11/13/2016. + */ +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 new file mode 100644 index 0000000000..d650bfb4ae --- /dev/null +++ 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 @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdcrests.vendorsoftwareproducts.types; + +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. + */ +public class OrchestrationTemplateActionResponseDto { + private List<String> fileNames; + private Map<String, List<ErrorMessage>> errors; + private UploadFileStatus status; + + public Map<String, List<ErrorMessage>> getErrors() { + return errors; + } + + public void setErrors(Map<String, List<ErrorMessage>> errors) { + this.errors = errors; + } + + public UploadFileStatus getStatus() { + return status; + } + + public void setStatus(UploadFileStatus status) { + this.status = status; + } + + public List<String> getFileNames() { + return fileNames; + } + + public void setFileNames(List<String> fileNames) { + this.fileNames = fileNames; + } + + public void addNewFileToList(String filename) { + this.fileNames.add(filename); + } + +} 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 5e689f3a0c..30bf8febda 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 @@ -20,6 +20,9 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +/** + * Created by TALIO on 4/25/2016. + */ public class PackageInfoDto { private String displayName; 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 e9c99b9d65..9e09503100 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 @@ -20,6 +20,8 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType; + import javax.validation.constraints.NotNull; public class ProcessRequestDto { @@ -29,6 +31,8 @@ public class ProcessRequestDto { private String description; + private ProcessType type; + public String getName() { return name; } @@ -44,4 +48,8 @@ public class ProcessRequestDto { public void setDescription(String description) { this.description = description; } + + public ProcessType getType() { return type; } + + public void setType(ProcessType type) { this.type = 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/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 81377764c2..5828feb736 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 @@ -20,9 +20,12 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +import org.openecomp.sdc.datatypes.error.ErrorMessage; + public class QuestionnaireResponseDto { private String schema; private String data; + private ErrorMessage errorMessage; public String getSchema() { return schema; @@ -39,4 +42,12 @@ public class QuestionnaireResponseDto { public void setData(String data) { this.data = data; } + + public ErrorMessage getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(ErrorMessage errorMessage) { + this.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 bf4805a9e1..c2bf49aa63 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 @@ -20,9 +20,12 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +import java.util.List; +import java.util.Set; + public class QuestionnaireValidationResultDto { private boolean valid; - private CompositionEntityValidationDataDto validationData; + private Set<CompositionEntityValidationDataDto> validationData; public boolean isValid() { return valid; @@ -32,11 +35,11 @@ public class QuestionnaireValidationResultDto { this.valid = valid; } - public CompositionEntityValidationDataDto getValidationData() { + public Set<CompositionEntityValidationDataDto> getValidationData() { return validationData; } - public void setValidationData(CompositionEntityValidationDataDto validationData) { + public void setValidationData(Set<CompositionEntityValidationDataDto> validationData) { this.validationData = 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 975f78d473..20a9472aeb 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 @@ -20,6 +20,9 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +/** + * Created by TALIO on 4/20/2016. + */ public class TranslatedFileDataDto { private String displayName; 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 4f57b8031f..a79c70a4d2 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 @@ -23,12 +23,13 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; 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. + */ public class UploadFileResponseDto { - private List<String> fileNames; private Map<String, List<ErrorMessage>> errors; private UploadFileStatus status; @@ -48,16 +49,4 @@ public class UploadFileResponseDto { this.status = status; } - public List<String> getFileNames() { - return fileNames; - } - - public void setFileNames(List<String> fileNames) { - this.fileNames = fileNames; - } - - public void addNewFileToList(String filename) { - this.fileNames.add(filename); - } - } 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 4ce2bf92f4..dbfdf346e4 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 @@ -20,6 +20,9 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +/** + * Created by TALIO on 4/20/2016. + */ public class VersionSoftwareProductActionRequestDto { private VendorSoftwareProductAction action; 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/VspCreationDto.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/VspCreationDto.java index d786017be1..f77005f781 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/VspCreationDto.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/VspCreationDto.java @@ -20,6 +20,9 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; +/** + * Created by TALIO on 4/26/2016. + */ public class VspCreationDto { private String vspId; 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 a2358a0b48..92e9d74bad 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 @@ -21,9 +21,13 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData; +import org.openecomp.sdcrests.common.types.VersionDto; import javax.validation.constraints.NotNull; +/** + * Created by TALIO on 4/20/2016. + */ public class VspDescriptionDto { @NotNull private String name; @@ -38,7 +42,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 VersionDto licensingVersion; // this will be populated with vlm version private LicensingData licensingData; public String getName() { @@ -97,11 +101,11 @@ public class VspDescriptionDto { this.vendorId = vendorId; } - public String getLicensingVersion() { + public VersionDto getLicensingVersion() { return licensingVersion; } - public void setLicensingVersion(String licensingVersion) { + public void setLicensingVersion(VersionDto licensingVersion) { this.licensingVersion = licensingVersion; } 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 85b3203099..d105acb406 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 @@ -21,22 +21,26 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import io.swagger.annotations.ApiModel; - import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; import org.openecomp.sdc.versioning.dao.types.VersionStatus; +import org.openecomp.sdcrests.common.types.VersionDto; import java.util.List; +/** + * Created by TALIO on 4/25/2016. + */ @ApiModel(value = "VspDetails") public class VspDetailsDto extends VspDescriptionDto { private String id; - private String version; - private List<String> viewableVersions; - private List<String> finalVersions; + private VersionDto version; + private List<VersionDto> viewableVersions; + private List<VersionDto> finalVersions; private VersionStatus status; private String lockingUser; private ValidationStructureList validationData; + private String isOldVersion; public String getId() { return id; @@ -46,27 +50,27 @@ public class VspDetailsDto extends VspDescriptionDto { this.id = id; } - public String getVersion() { + public VersionDto getVersion() { return version; } - public void setVersion(String version) { + public void setVersion(VersionDto version) { this.version = version; } - public List<String> getViewableVersions() { + public List<VersionDto> getViewableVersions() { return viewableVersions; } - public void setViewableVersions(List<String> viewableVersions) { + public void setViewableVersions(List<VersionDto> viewableVersions) { this.viewableVersions = viewableVersions; } - public List<String> getFinalVersions() { + public List<VersionDto> getFinalVersions() { return finalVersions; } - public void setFinalVersions(List<String> finalVersions) { + public void setFinalVersions(List<VersionDto> finalVersions) { this.finalVersions = finalVersions; } @@ -90,8 +94,18 @@ public class VspDetailsDto extends VspDescriptionDto { return validationData; } + public String getIsOldVersion() { + return isOldVersion; + } + + public void setIsOldVersion(String isOldVersion) { + this.isOldVersion = isOldVersion; + } + public void setValidationData(ValidationStructureList validationData) { this.validationData = 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/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 23d90c02a2..9e0b08bd0d 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 @@ -25,6 +25,7 @@ import org.openecomp.core.utilities.json.JsonUtil; import javax.validation.ConstraintValidator; import javax.validation.ConstraintValidatorContext; + public class CustomJsonValidator implements ConstraintValidator<IsValidJson, String> { @Override 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 7a9ec50721..5109002978 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 @@ -20,6 +20,9 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types.validation; +/** + * @since July 13, 2016 + */ import static java.lang.annotation.ElementType.ANNOTATION_TYPE; import static java.lang.annotation.ElementType.CONSTRUCTOR; @@ -30,15 +33,12 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; import org.openecomp.sdcrests.common.RestConstants; - import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; - import javax.validation.Constraint; import javax.validation.Payload; - /** * The interface Is valid json. */ |