Fix Sonar issue with throw generic exception on apihandlerinfra 50/101150/4
authorTomasz Wrobel <tomasz.wrobel@nokia.com>
Wed, 5 Feb 2020 07:11:23 +0000 (08:11 +0100)
committerTomasz Wrobel <tomasz.wrobel@nokia.com>
Wed, 5 Feb 2020 11:27:08 +0000 (12:27 +0100)
Issue-ID: SO-2645
Signed-off-by: Tomasz Wrobel <tomasz.wrobel@nokia.com>
Change-Id: I111ca7c7bef271386bd075e2b948f29d7c2b4516

mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Network.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/ServiceInstance.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/VfModules.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Vnf.java
mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/Volumes.java

index 483ac47..3104c84 100644 (file)
@@ -32,9 +32,14 @@ import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import com.fasterxml.jackson.core.JsonProcessingException;
 import org.onap.logging.ref.slf4j.ONAPLogConstants;
 import org.onap.so.apihandler.filters.ResponseUpdater;
 import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnectionException;
 import org.onap.so.apihandlerinfra.infra.rest.handler.NetworkRestHandler;
 import org.onap.so.db.catalog.beans.Recipe;
 import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -71,14 +76,15 @@ public class Network {
     public Response deleteNetworkInstance(@PathParam("version") String version,
             @PathParam("serviceInstanceId") String serviceInstanceId,
             @PathParam("networkInstanceId") String networkInstanceId, @Context ContainerRequestContext requestContext)
-            throws Exception {
-        InfraActiveRequests currentRequest = null;
+            throws AAIEntityNotFound, NoRecipeException, JsonProcessingException, WorkflowEngineConnectionException,
+            ValidateException {
+
         String requestId = networkRestHandler.getRequestId(requestContext);
         String requestorId = "Unknown";
         String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
         String requestURI = requestContext.getUriInfo().getAbsolutePath().toString();
-        currentRequest = networkRestHandler.createInfraActiveRequestForDelete(requestId, serviceInstanceId,
-                networkInstanceId, requestorId, source, requestURI);
+        InfraActiveRequests currentRequest = networkRestHandler.createInfraActiveRequestForDelete(requestId,
+                serviceInstanceId, networkInstanceId, requestorId, source, requestURI);
         ServiceInstancesRequest request = requestBuilder.buildNetworkDeleteRequest(networkInstanceId);
         networkRestHandler.saveInstanceName(request, currentRequest);
         networkRestHandler.checkDuplicateRequest(serviceInstanceId, networkInstanceId,
index 135667d..7aaf470 100644 (file)
@@ -32,9 +32,14 @@ import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import com.fasterxml.jackson.core.JsonProcessingException;
 import org.onap.logging.ref.slf4j.ONAPLogConstants;
 import org.onap.so.apihandler.filters.ResponseUpdater;
 import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnectionException;
 import org.onap.so.apihandlerinfra.infra.rest.handler.ServiceInstanceRestHandler;
 import org.onap.so.db.catalog.beans.Recipe;
 import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -70,14 +75,15 @@ public class ServiceInstance {
     @Transactional
     public Response deleteServiceInstance(@PathParam("version") String version,
             @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext)
-            throws Exception {
-        InfraActiveRequests currentRequest = null;
+            throws AAIEntityNotFound, NoRecipeException, JsonProcessingException, WorkflowEngineConnectionException,
+            ValidateException {
+
         String requestId = requestHandler.getRequestId(requestContext);
         String requestorId = "Unknown";
         String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
         String requestURI = requestContext.getUriInfo().getAbsolutePath().toString();
-        currentRequest = requestHandler.createInfraActiveRequestForDelete(requestId, serviceInstanceId, requestorId,
-                source, requestURI);
+        InfraActiveRequests currentRequest = requestHandler.createInfraActiveRequestForDelete(requestId,
+                serviceInstanceId, requestorId, source, requestURI);
         ServiceInstancesRequest request = requestBuilder.buildServiceDeleteRequest(serviceInstanceId);
         requestHandler.saveInstanceName(request, currentRequest);
         requestHandler.checkDuplicateRequest(serviceInstanceId,
index 4a86d94..ddbced9 100644 (file)
@@ -9,9 +9,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.
@@ -32,9 +32,14 @@ import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import com.fasterxml.jackson.core.JsonProcessingException;
 import org.onap.logging.ref.slf4j.ONAPLogConstants;
 import org.onap.so.apihandler.filters.ResponseUpdater;
 import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnectionException;
 import org.onap.so.apihandlerinfra.infra.rest.handler.VFModuleRestHandler;
 import org.onap.so.db.catalog.beans.Recipe;
 import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -72,15 +77,15 @@ public class VfModules {
     public Response deleteVfModuleInstance(@PathParam("version") String version,
             @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId,
             @PathParam("vfmoduleInstanceId") String vfmoduleInstanceId, @Context ContainerRequestContext requestContext)
-            throws Exception {
-        InfraActiveRequests currentRequest = null;
+            throws AAIEntityNotFound, NoRecipeException, JsonProcessingException, WorkflowEngineConnectionException,
+            ValidateException {
 
         String requestId = restHandler.getRequestId(requestContext);
         String requestorId = "Unknown";
         String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
         String requestURL = requestContext.getUriInfo().getAbsolutePath().toString();
-        currentRequest = restHandler.createInfraActiveRequestForDelete(requestId, vfmoduleInstanceId, serviceInstanceId,
-                vnfInstanceId, requestorId, source, requestURL);
+        InfraActiveRequests currentRequest = restHandler.createInfraActiveRequestForDelete(requestId,
+                vfmoduleInstanceId, serviceInstanceId, vnfInstanceId, requestorId, source, requestURL);
         ServiceInstancesRequest request =
                 requestBuilder.buildVFModuleDeleteRequest(vnfInstanceId, vfmoduleInstanceId, ModelType.vfModule);
         restHandler.saveInstanceName(request, currentRequest);
index edb0908..68e6eb5 100644 (file)
@@ -32,8 +32,12 @@ import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import com.fasterxml.jackson.core.JsonProcessingException;
 import org.onap.logging.ref.slf4j.ONAPLogConstants;
 import org.onap.so.apihandler.filters.ResponseUpdater;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
+import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnectionException;
 import org.onap.so.apihandlerinfra.infra.rest.handler.VnfRestHandler;
 import org.onap.so.db.catalog.beans.Recipe;
 import org.onap.so.db.request.beans.InfraActiveRequests;
@@ -69,14 +73,15 @@ public class Vnf {
     @Transactional
     public Response deleteVnfInstance(@PathParam("version") String version,
             @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId,
-            @Context ContainerRequestContext requestContext) throws Exception {
-        InfraActiveRequests currentRequest = null;
+            @Context ContainerRequestContext requestContext)
+            throws AAIEntityNotFound, JsonProcessingException, WorkflowEngineConnectionException, ValidateException {
+
         String requestId = vnfRestHandler.getRequestId(requestContext);
         String requestorId = "Unknown";
         String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
         String requestURL = requestContext.getUriInfo().getAbsolutePath().toString();
-        currentRequest = vnfRestHandler.createInfraActiveRequestForDelete(requestId, serviceInstanceId, vnfInstanceId,
-                requestorId, source, requestURL);
+        InfraActiveRequests currentRequest = vnfRestHandler.createInfraActiveRequestForDelete(requestId,
+                serviceInstanceId, vnfInstanceId, requestorId, source, requestURL);
         ServiceInstancesRequest request = requestBuilder.buildVnfDeleteRequest(vnfInstanceId);
         vnfRestHandler.saveInstanceName(request, currentRequest);
         vnfRestHandler.checkDuplicateRequest(serviceInstanceId, vnfInstanceId,
index 3154c86..b842580 100644 (file)
@@ -32,9 +32,14 @@ import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import com.fasterxml.jackson.core.JsonProcessingException;
 import org.onap.logging.ref.slf4j.ONAPLogConstants;
 import org.onap.so.apihandler.filters.ResponseUpdater;
 import org.onap.so.apihandlerinfra.Action;
+import org.onap.so.apihandlerinfra.exceptions.ValidateException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.AAIEntityNotFound;
+import org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException;
+import org.onap.so.apihandlerinfra.infra.rest.exception.WorkflowEngineConnectionException;
 import org.onap.so.apihandlerinfra.infra.rest.handler.VFModuleRestHandler;
 import org.onap.so.apihandlerinfra.infra.rest.handler.VolumeRestHandler;
 import org.onap.so.db.catalog.beans.Recipe;
@@ -76,14 +81,15 @@ public class Volumes {
     public Response deleteVfModuleInstance(@PathParam("version") String version,
             @PathParam("serviceInstanceId") String serviceInstanceId, @PathParam("vnfInstanceId") String vnfInstanceId,
             @PathParam("volumeGroupInstanceId") String volumeGroupId, @Context ContainerRequestContext requestContext)
-            throws Exception {
-        InfraActiveRequests currentRequest = null;
+            throws AAIEntityNotFound, NoRecipeException, JsonProcessingException, WorkflowEngineConnectionException,
+            ValidateException {
+
         String requestId = volumeRestHandler.getRequestId(requestContext);
         String requestorId = "Unknown";
         String source = MDC.get(ONAPLogConstants.MDCs.PARTNER_NAME);
         String requestURL = requestContext.getUriInfo().getAbsolutePath().toString();
-        currentRequest = volumeRestHandler.createInfraActiveRequestForDelete(requestId, volumeGroupId,
-                serviceInstanceId, vnfInstanceId, requestorId, source, requestURL);
+        InfraActiveRequests currentRequest = volumeRestHandler.createInfraActiveRequestForDelete(requestId,
+                volumeGroupId, serviceInstanceId, vnfInstanceId, requestorId, source, requestURL);
         ServiceInstancesRequest request = requestBuilder.buildVolumeGroupDeleteRequest(vnfInstanceId, volumeGroupId);
         volumeRestHandler.saveInstanceName(request, currentRequest);
         volumeRestHandler.checkDuplicateRequest(serviceInstanceId, vnfInstanceId, volumeGroupId,