Fix Sonar issue - throw generic exception. 15/101215/5
authorTomasz Wrobel <tomasz.wrobel@nokia.com>
Thu, 6 Feb 2020 07:46:30 +0000 (08:46 +0100)
committerTomasz Wróbel <tomasz.wrobel@nokia.com>
Thu, 6 Feb 2020 13:38:01 +0000 (13:38 +0000)
Issue-ID: SO-1841
Signed-off-by: Tomasz Wrobel <tomasz.wrobel@nokia.com>
Change-Id: Ia24bdb36f03a1b96a356ef27fe1dca95e48adb7c

bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/CreateNetworkCollection.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceCreateTasks.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/namingservice/tasks/NamingServiceDeleteTasks.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/sdnc/tasks/SDNCQueryTasks.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/VnfAdapterVolumeGroupResources.java

index 533dd89..4522f7f 100644 (file)
@@ -24,6 +24,7 @@
 
 package org.onap.so.bpmn.infrastructure.activity;
 
+import java.io.IOException;
 import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
@@ -89,8 +90,8 @@ public class ExecuteActivity implements JavaDelegate {
     @Override
     public void execute(DelegateExecution execution) throws Exception {
         final String requestId = (String) execution.getVariable(G_REQUEST_ID);
-        WorkflowException workflowException = null;
-        String handlingCode = null;
+        WorkflowException workflowException;
+        String handlingCode;
         try {
             Boolean workflowSyncAckSent = (Boolean) execution.getVariable(WORKFLOW_SYNC_ACK_SENT);
             if (workflowSyncAckSent == null || workflowSyncAckSent == false) {
@@ -114,7 +115,7 @@ public class ExecuteActivity implements JavaDelegate {
             if (execution.getVariables() != null) {
                 execution.getVariables().forEach((key, value) -> {
                     if (value instanceof Serializable) {
-                        variables.put(key, (Serializable) value);
+                        variables.put(key, value);
                     }
                 });
             }
@@ -153,25 +154,22 @@ public class ExecuteActivity implements JavaDelegate {
     }
 
     protected BuildingBlock buildBuildingBlock(String activityName) {
-        BuildingBlock buildingBlock = new BuildingBlock().setBpmnFlowName(activityName)
-                .setMsoId(UUID.randomUUID().toString()).setKey("").setIsVirtualLink(false).setVirtualLinkKey("");
-        return buildingBlock;
+        return new BuildingBlock().setBpmnFlowName(activityName).setMsoId(UUID.randomUUID().toString()).setKey("")
+                .setIsVirtualLink(false).setVirtualLinkKey("");
     }
 
     protected ExecuteBuildingBlock buildExecuteBuildingBlock(DelegateExecution execution, String requestId,
-            BuildingBlock buildingBlock) throws Exception {
+            BuildingBlock buildingBlock) throws IOException {
         WorkflowResourceIds workflowResourceIds = new WorkflowResourceIds();
         workflowResourceIds.setServiceInstanceId((String) execution.getVariable(SERVICE_INSTANCE_ID));
         workflowResourceIds.setVnfId((String) execution.getVariable(VNF_ID));
         String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST);
         ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
         RequestDetails requestDetails = sIRequest.getRequestDetails();
-        ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setaLaCarte(true)
-                .setRequestAction((String) execution.getVariable(G_ACTION))
+        return new ExecuteBuildingBlock().setaLaCarte(true).setRequestAction((String) execution.getVariable(G_ACTION))
                 .setResourceId((String) execution.getVariable(VNF_ID))
                 .setVnfType((String) execution.getVariable(VNF_TYPE)).setWorkflowResourceIds(workflowResourceIds)
                 .setRequestId(requestId).setBuildingBlock(buildingBlock).setRequestDetails(requestDetails);
-        return executeBuildingBlock;
     }
 
     protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) {
index 164480d..ff0f9e7 100644 (file)
@@ -6,6 +6,8 @@
  * ================================================================================
  * Modifications Copyright (c) 2019 Samsung
  * ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -46,17 +48,16 @@ public class AssignNetwork {
      * @return
      */
     public boolean networkFoundByName(BuildingBlockExecution execution) {
-        boolean networkFound = false;
         try {
             L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
 
             if (!OrchestrationStatus.PRECREATED.equals(l3network.getOrchestrationStatus())) {
-                networkFound = true;
                 logger.debug("network found in NOT PRECREATED status");
+                return true;
             }
         } catch (Exception ex) {
-            // return false if no network present
+            return false;
         }
-        return networkFound;
+        return false;
     }
 }
index 36eab8f..5e925bf 100644 (file)
@@ -6,6 +6,8 @@
  * ================================================================================
  * Modifications Copyright (c) 2019 Samsung
  * ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -29,8 +31,6 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
 import org.onap.so.client.exception.ExceptionBuilder;
 import org.onap.so.client.orchestration.AAINetworkResources;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
index ea0b408..ccbce2d 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 package org.onap.so.bpmn.infrastructure.namingservice.tasks;
 
-import java.util.List;
-import java.util.Optional;
-import org.onap.aai.domain.yang.Zone;
 import org.onap.so.bpmn.common.BuildingBlockExecution;
 import org.onap.so.bpmn.common.InjectionHelper;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding;
-import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
 import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
-import org.onap.so.client.aai.AAIObjectType;
-import org.onap.so.client.aai.entities.AAIResultWrapper;
-import org.onap.so.client.aai.entities.Relationships;
-import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.exception.BBObjectNotFoundException;
 import org.onap.so.client.exception.ExceptionBuilder;
 import org.onap.so.client.namingservice.NamingRequestObject;
 import org.onap.so.client.namingservice.NamingServiceConstants;
@@ -65,7 +58,7 @@ public class NamingServiceCreateTasks {
         this.bbInputSetupUtils = bbInputSetupUtils;
     }
 
-    public void createInstanceGroupName(BuildingBlockExecution execution) throws Exception {
+    public void createInstanceGroupName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
         InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
         String policyInstanceName = execution.getVariable("policyInstanceName");
         String nfNamingCode = execution.getVariable("nfNamingCode");
@@ -79,7 +72,7 @@ public class NamingServiceCreateTasks {
         instanceGroup.setInstanceGroupName(generatedInstanceGroupName);
     }
 
-    public void createWanTransportServiceName(BuildingBlockExecution execution) throws Exception {
+    public void createWanTransportServiceName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
         ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
         NamingRequestObject namingRequestObject = new NamingRequestObject();
         namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId());
@@ -98,7 +91,7 @@ public class NamingServiceCreateTasks {
         serviceInstance.setServiceInstanceName(generatedWanTransportServiceName);
     }
 
-    public void createVpnBondingServiceName(BuildingBlockExecution execution) throws Exception {
+    public void createVpnBondingServiceName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
         ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
         L3Network network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
         VpnBinding vpnBinding = extractPojosForBB.extractByKey(execution, ResourceKey.VPN_ID);
index 507e14e..8d14bd3 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -26,6 +28,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.exception.BBObjectNotFoundException;
 import org.onap.so.client.exception.ExceptionBuilder;
 import org.onap.so.client.namingservice.NamingRequestObject;
 import org.onap.so.client.orchestration.NamingServiceResources;
@@ -43,7 +46,7 @@ public class NamingServiceDeleteTasks {
     @Autowired
     private NamingServiceResources namingServiceResources;
 
-    public void deleteInstanceGroupName(BuildingBlockExecution execution) throws Exception {
+    public void deleteInstanceGroupName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
         InstanceGroup instanceGroup = extractPojosForBB.extractByKey(execution, ResourceKey.INSTANCE_GROUP_ID);
 
         try {
@@ -53,7 +56,7 @@ public class NamingServiceDeleteTasks {
         }
     }
 
-    public void deleteServiceInstanceName(BuildingBlockExecution execution) throws Exception {
+    public void deleteServiceInstanceName(BuildingBlockExecution execution) throws BBObjectNotFoundException {
         ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
         NamingRequestObject namingRequestObject = new NamingRequestObject();
         namingRequestObject.setExternalKeyValue(serviceInstance.getServiceInstanceId());
index 192cb3f..89d62e0 100644 (file)
@@ -6,6 +6,8 @@
  * ================================================================================
  * Modifications Copyright (c) 2019 Samsung
  * ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -64,7 +66,7 @@ public class SDNCQueryTasks {
      * @param execution
      * @throws Exception
      */
-    public void queryVnf(BuildingBlockExecution execution) throws Exception {
+    public void queryVnf(BuildingBlockExecution execution) throws BBObjectNotFoundException {
         ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
         GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
 
@@ -99,7 +101,7 @@ public class SDNCQueryTasks {
      * @param execution
      * @throws Exception
      */
-    public void queryVfModule(BuildingBlockExecution execution) throws Exception {
+    public void queryVfModule(BuildingBlockExecution execution) throws BBObjectNotFoundException {
         ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
         GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
         VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
index 2ec6318..35e0856 100644 (file)
@@ -6,6 +6,8 @@
  * ================================================================================
  * Modifications Copyright (c) 2019 Samsung
  * ================================================================================
+ * Modifications Copyright (c) 2020 Nokia
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -32,10 +34,9 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext
 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
 import org.onap.so.client.adapter.vnf.VnfVolumeAdapterClientImpl;
 import org.onap.so.client.adapter.vnf.mapper.VnfAdapterObjectMapper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+import java.io.IOException;
 
 @Component
 public class VnfAdapterVolumeGroupResources {
@@ -48,13 +49,13 @@ public class VnfAdapterVolumeGroupResources {
 
     public CreateVolumeGroupRequest createVolumeGroupRequest(RequestContext requestContext, CloudRegion cloudRegion,
             OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf,
-            VolumeGroup volumeGroup, String sdncVfModuleQueryResponse) throws Exception {
+            VolumeGroup volumeGroup, String sdncVfModuleQueryResponse) throws IOException {
         return vnfAdapterObjectMapper.createVolumeGroupRequestMapper(requestContext, cloudRegion, orchestrationContext,
                 serviceInstance, genericVnf, volumeGroup, sdncVfModuleQueryResponse);
     }
 
     public DeleteVolumeGroupRequest deleteVolumeGroupRequest(RequestContext requestContext, CloudRegion cloudRegion,
-            ServiceInstance serviceInstance, VolumeGroup volumeGroup) throws Exception {
+            ServiceInstance serviceInstance, VolumeGroup volumeGroup) throws IOException {
         return vnfAdapterObjectMapper.deleteVolumeGroupRequestMapper(requestContext, cloudRegion, serviceInstance,
                 volumeGroup);
     }