General Sonar fixes and improvements 62/89362/2
authorr.bogacki <r.bogacki@samsung.com>
Wed, 5 Jun 2019 12:11:00 +0000 (14:11 +0200)
committerRobert Bogacki <r.bogacki@samsung.com>
Wed, 5 Jun 2019 12:15:13 +0000 (12:15 +0000)
General fixes and improvements according to the Sonar analysis.
-Fixed imports.
-Removed unnecessary variables.
-Protect utility static classes with private constructor.
-Removed unnecessary exceptions.

Issue-ID: SO-1992
Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
Change-Id: Ib0011d730f86e0e1a25d4cf1080a61b2fbb335ae

bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/recipe/BpmnRestClient.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/ResourceRequestBuilder.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/BuildingBlockValidatorRunner.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/FlowValidator.java
bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/validation/WorkflowValidatorRunner.java

index b9ee360..654dabb 100644 (file)
@@ -63,16 +63,12 @@ public class BpmnRestClient {
 
     public static final String CAMUNDA_AUTH = "mso.camundaAuth";
 
-    private static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
     @Autowired
     private UrnPropertiesReader urnPropertiesReader;
 
     private static boolean noProperties = true;
 
-    // because for NS it will take a long time the time out of the resouce will be 2 hours.
-    private static final String DEFAULT_TIME_OUT = "7200";
-
-    public synchronized final boolean getNoPropertiesState() {
+    public final synchronized boolean getNoPropertiesState() {
         return noProperties;
     }
 
@@ -94,7 +90,7 @@ public class BpmnRestClient {
      */
     public HttpResponse post(String recipeUri, String requestId, int recipeTimeout, String requestAction,
             String serviceInstanceId, String serviceType, String requestDetails, String recipeParamXsd)
-            throws ClientProtocolException, IOException {
+            throws IOException {
 
         HttpClient client = HttpClientBuilder.create().build();
 
@@ -164,7 +160,7 @@ public class BpmnRestClient {
             BpmnParam recipeParamsInput = new BpmnParam();
             BpmnIntegerParam recipeTimeoutInput = new BpmnIntegerParam();
             recipeTimeoutInput.setValue(recipeTimeout);
-            // host.setValue(parseURL());
+
             requestIdInput.setValue(requestId);
             requestActionInput.setValue(requestAction);
             serviceInstanceIdInput.setValue(serviceInstanceId);
index cc62865..2b650e1 100644 (file)
@@ -31,13 +31,16 @@ import org.onap.so.bpmn.core.domain.VnfResource;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 
 public class InstanceResourceList {
 
+    private InstanceResourceList() {
+        throw new IllegalStateException("Utility class");
+    }
+
     private static Map<String, List<List<GroupResource>>> convertUUIReqTOStd(final JsonObject reqInputJsonObj,
             List<Resource> seqResourceList) {
 
index 9d0b9e4..faa3d74 100644 (file)
@@ -41,7 +41,6 @@ import org.onap.so.bpmn.core.domain.GroupResource;
 import org.onap.so.bpmn.core.domain.Resource;
 import org.onap.so.bpmn.core.domain.ResourceType;
 import org.onap.so.bpmn.core.domain.VnfResource;
-import org.onap.so.bpmn.core.domain.VnfcResource;
 import org.onap.so.bpmn.core.json.JsonUtils;
 import org.onap.so.client.HttpClient;
 import org.onap.so.client.HttpClientFactory;
@@ -56,14 +55,16 @@ import org.slf4j.LoggerFactory;
 
 public class ResourceRequestBuilder {
 
-    private static String CUSTOMIZATION_UUID = "cuserviceResourcesstomizationUUID";
-
     private static String SERVICE_URL_SERVICE_INSTANCE = "/v2/serviceResources";
 
     private static Logger logger = LoggerFactory.getLogger(ResourceRequestBuilder.class);
 
     static JsonUtils jsonUtil = new JsonUtils();
 
+    private ResourceRequestBuilder() {
+        throw new IllegalStateException("Utility class");
+    }
+
     public static List<String> getResourceSequence(String serviceUuid) {
 
         List<String> resourceSequence = new ArrayList();
@@ -111,7 +112,7 @@ public class ResourceRequestBuilder {
         String locationConstraints = "[]";
         if (resource.getResourceType() == ResourceType.VNF) {
             for (String eachResource : resourceList) {
-                String resCusUuid = (String) JsonUtils.getJsonValue(eachResource, "resourceCustomizationUuid");
+                String resCusUuid = JsonUtils.getJsonValue(eachResource, "resourceCustomizationUuid");
                 if ((null != resCusUuid) && resCusUuid.equals(resource.getModelInfo().getModelCustomizationUuid())) {
                     String resourceParameters = JsonUtils.getJsonValue(eachResource, "parameters");
                     locationConstraints = JsonUtils.getJsonValue(resourceParameters, "locationConstraints");
@@ -156,7 +157,6 @@ public class ResourceRequestBuilder {
                     break;
             }
 
-            Map<String, Object> resourceInputsAfterMerge = new HashMap<>();
             if (StringUtils.isNotEmpty(resourceInputStr)) {
                 return getResourceInput(resourceInputStr, uuiRequestInputs, resourceLevel, currentVFData);
             }
index a8e43c5..7777584 100644 (file)
 
 package org.onap.so.bpmn.common.validation;
 
-import java.lang.annotation.Annotation;
 import java.util.ArrayList;
-import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Optional;
-import java.util.stream.Collectors;
 import javax.annotation.PostConstruct;
-import javax.annotation.Priority;
-import org.camunda.bpm.engine.delegate.BpmnError;
-import org.javatuples.Pair;
-import org.onap.so.bpmn.common.BuildingBlockExecution;
-import org.onap.so.client.exception.ExceptionBuilder;
-import org.reflections.Reflections;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
 import org.springframework.stereotype.Component;
 
 
index 66a8de9..05d7a1f 100644 (file)
@@ -21,7 +21,6 @@
 package org.onap.so.bpmn.common.validation;
 
 import java.util.Optional;
-import java.util.Set;
 import org.onap.so.bpmn.common.BuildingBlockExecution;
 
 public interface FlowValidator {
@@ -30,6 +29,7 @@ public interface FlowValidator {
      * Should this validator run for given bb
      * 
      * @return
+     * 
      */
     public boolean shouldRunFor(String bbName);
 
index 6950618..493bb0e 100644 (file)
 
 package org.onap.so.bpmn.common.validation;
 
-import java.lang.annotation.Annotation;
 import java.util.ArrayList;
-import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Optional;
-import java.util.stream.Collectors;
 import javax.annotation.PostConstruct;
-import javax.annotation.Priority;
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.javatuples.Pair;
-import org.onap.so.client.exception.ExceptionBuilder;
-import org.reflections.Reflections;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
 import org.springframework.stereotype.Component;