aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml32
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/pom.xml.versionsBackup143
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/Actions.java124
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/ActionsForSwaggerFileUpload.java104
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/mapping/MapActionToActionResponseDto.java1
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/action-library-rest/action-library-rest-services/src/main/java/org/openecomp/sdcrests/action/rest/services/ActionsImpl.java737
6 files changed, 711 insertions, 430 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) {